aliaxon
aliaxon
FFilament
Created by aliaxon on 6/2/2023 in #❓┊help
Last Nested Select component doesn't work with ->multiple() function attached to it
When trying to chain the dependent select, the last select doesn't work with multiple() attached to it, any guidance in the right direction would be highly appreciated! protected function getFormSchema(): array { return [ Grid::make(2) ->schema([ Forms\Components\Select::make('section_id') ->label('Sections') ->options(Section::where('is_active',true) ->orderBy('name','asc') ->pluck('name','id') ) ->required() ->reactive() ->callAfterStateUpdated(fn (callable $set) => $set($this->certification_id, null)), Forms\Components\Select::make('certification_id') ->label('Certification') ->options(Certification::where('is_active',true) ->where('section_id',$this->section_id) ->orderBy('name','asc') ->pluck('name','id') ) ->preload() ->required() ->reactive() ->callAfterStateUpdated(fn (callable $set) => $set($this->domains, null)), Forms\Components\Select::make('domains') ->options(Domain::where('is_active',true) ->where('certification_id',$this->certification_id) ->orderBy('name','asc') ->pluck('name','id') ) // ->multiple() ->preload() ->required(), ]; } If I remove ->multiple() from the last select, it works and the values and listed down in the dropdown. Thanks in advance !
8 replies
FFilament
Created by aliaxon on 5/27/2023 in #❓┊help
Passing parent id to child create view
Hi there, I have a parent child relations between Section and Certification model, hasMany and belongsTo functions are defined. When I'm on SecionResource, Section is displayed as master and this "Create Certification" button is there. I want to pass and add section_id into "data" variable when I open to modal so that I don't have to fillin the Section_id while creating the certification. I add user_id as below: class CreateCertification extends CreateRecord { protected static string $resource = CertificationResource::class; protected function mutateFormDataBeforeCreate(array $data): array { $data['user_id'] = auth()->id(); return $data; } protected function getRedirectUrl(): string { return $this->getResource()::getUrl('index'); } } I wonder how to pass on the section_id and add it to $data so that the dropdown select with all sections is not needed when creation the certification record Many thanks in advance!!
1 replies