#Custom Field: Using Form Components
6 messages · Page 1 of 1 (latest)
If it's a custom field, just extend the original and add whatever custom logic you are using.
i need to have a something like a form, and use a combination of filament form components.
i've succeeded at making what i want, but i'm not sure if it's the right approach.
protected ?ComponentContainer $childComponentContainer = null;
protected function setUp(): void
{
parent::setUp();
}
public function getChildComponents(): array
{
if (!$this->childComponentContainer) {
$this->childComponentContainer = ComponentContainer::make($this->getLivewire())
->components($this->getFormSchema());
}
return $this->childComponentContainer->getComponents();
}
protected function getFormSchema(): array
{
return [
Select::make('type')
->options([
'option1' => 'Option 1',
'option2' => 'Option 2',
])
->live()
->required()
->afterStateUpdated(function () {
logger()->debug('iiiiii');
}),
TextInput::make('value')
->required()
->maxLength(255),
];
}
and in the field view:
<div>
@foreach($getChildComponents() as $component)
{{ $component->render() }}
@endforeach
</div>
why would you like to add a field inside custom field?
i'm making an invoice page, and in the section where the user should add products i want it to be something like in this image below.
I thought that the default filament repeater wouldn't do it, so i thought of making it a field, since i'll be using it also for quotes, invoices etc.
any better suggestions, i may be taking a wrong path here