F
Filament6mo ago
Aminne

How i can disable submit button until form is fully validated filament

Forms\Components\Select::make('from_id')->relationship(name: 'from',
modifyQueryUsing: fn (Builder $query, Get $get) => $query->where('id', '!=', $get('to_id')))
->getOptionLabelFromRecordUsing(fn (Model $record) => "{$record->holder->name}")
->preload()
->searchable()
->required()
->live(onBlur: true)
->afterStateUpdated(function (Forms\Contracts\HasForms $livewire, Forms\Components\Select $component) {
$livewire->validateOnly($component->getStatePath());})->rules([
fn () => function (string $attribute, $value, Closure $fail) {
$wallet = Wallet::find($value);
if(intval($wallet->balance) === 0) {$fail('The :attribute wallet is empty.');},]),
Forms\Components\Select::make('from_id')->relationship(name: 'from',
modifyQueryUsing: fn (Builder $query, Get $get) => $query->where('id', '!=', $get('to_id')))
->getOptionLabelFromRecordUsing(fn (Model $record) => "{$record->holder->name}")
->preload()
->searchable()
->required()
->live(onBlur: true)
->afterStateUpdated(function (Forms\Contracts\HasForms $livewire, Forms\Components\Select $component) {
$livewire->validateOnly($component->getStatePath());})->rules([
fn () => function (string $attribute, $value, Closure $fail) {
$wallet = Wallet::find($value);
if(intval($wallet->balance) === 0) {$fail('The :attribute wallet is empty.');},]),
No description
1 Reply
Aminne
AminneOP6mo ago
I added this code
])->extraModalFooterActions(fn (Actions\Action $action): array => [
$action->makeModalSubmitAction('submit')
->color('info')
->disabled()
])
])->extraModalFooterActions(fn (Actions\Action $action): array => [
$action->makeModalSubmitAction('submit')
->color('info')
->disabled()
])
Want results from more Discord servers?
Add your server