F
Filament14mo ago
Lodret

State of Select Relationship

How i get state for relationship select input form builder in my applications, i selected tags by the data tags in table tags, but when i i get the state data by hook
protected function beforeSave(): void
{
dd($this->form->getState());
}
protected function beforeSave(): void
{
dd($this->form->getState());
}
public static function getTagsFormComponent()
{
return Select::make('tags')
->inlineLabel()
->multiple()
->label('Tags')
->relationship(name: 'tags', titleAttribute: 'nama')->searchable(['nama'])
->options(Tags::select('id', 'nama')->pluck('nama', 'id'))
->preload()
->createOptionForm([
Hidden::make('is_active')->default(1),
TextInput::make('nama')
->required(),
])
->native(false);
}
public static function getTagsFormComponent()
{
return Select::make('tags')
->inlineLabel()
->multiple()
->label('Tags')
->relationship(name: 'tags', titleAttribute: 'nama')->searchable(['nama'])
->options(Tags::select('id', 'nama')->pluck('nama', 'id'))
->preload()
->createOptionForm([
Hidden::make('is_active')->default(1),
TextInput::make('nama')
->required(),
])
->native(false);
}
No description
2 Replies
Rupadana
Rupadana14mo ago
what do you mean? are 'tags' relationship is not parsed to form state?
Lodret
LodretOP14mo ago
im sorry nvm, i ever test the code and then the relatinship tags belongsToMany is actually work after i test
Want results from more Discord servers?
Add your server