How mutateFormDataBeforeFill get the data?

Hi, I create a custom component as I say you few days ago. And I set a select inside. Component view:
{{ $getSelectComponent() }}
{{ $getSelectComponent() }}
Component controller:
public function getSelectComponent(): ComponentContainer
{
return ComponentContainer::make($this->getLivewire())
->parentComponent($this)
->components([
Select::make(Str::slug($this->heading.' status'))->options($this->options)
]);
}
public function getSelectComponent(): ComponentContainer
{
return ComponentContainer::make($this->getLivewire())
->parentComponent($this)
->components([
Select::make(Str::slug($this->heading.' status'))->options($this->options)
]);
}
The select is printed well, but when I click the save button, the data don't appears in the $data variable of mutateFormDataBeforeFill function of editRecord. Why can this be? Is it necessary to include this id in a list or simply by being inside the form should it be taken automatically?
9 Replies
Dan Harrin
Dan Harrin2y ago
because this component container isnt actually registered anywhere so filament doesnt know to look for the select inside essentially getChildComponentContainers() needs to return an array of all containers with components so the default getChildComponentContainer() and then your getSelectComponent()
jals65
jals65OP2y ago
@Dan Harrin I have finally managed to get the data out with implements HasValidationRules and use CanBeValidated
Dan Harrin
Dan Harrin2y ago
hmmm why? you just need to register the containers in the component class
jals65
jals65OP2y ago
How can I do that?
Dan Harrin
Dan Harrin2y ago
getChildComponentContainers() should return [$this->getChildComponentContainer(), $this->getSelectComponent()]
jals65
jals65OP2y ago
It doesn't works for me because the custom component that I'm making is a Section, and it have another childComponents.
jals65
jals65OP2y ago
The fields that i get the data are status and text area that are a fixed fields in the component with a modal. Yo can see in the top right corner
Dan Harrin
Dan Harrin2y ago
yes but you only need to render the main child component container within the section and then register the container/s for the modal component/s so that they get discovered by filament
jals65
jals65OP2y ago
Ok, thanks @Dan Harrin
Want results from more Discord servers?
Add your server