Access any field from form with anonymous action
Hello everybody,
I have an anonymous function right in the middle of a form,
I want to access my "quantity" field from the action() method of my anonymous function.
How to do ? I didn't find much choice in the documentation or on the internet...
Thank's
Solution:Jump to solution
```php
->action(function (\Filament\Forms\Components\Component $component) {
$container = $component->getContainer()->getParentComponent()->getContainer();
$quantity = $container->getComponent('data.quantity');
//$quantity->getStep()...
5 Replies
$get('quantity')
?This method only retrieves the value of my field. And this is the only interaction we can have with anonymous form functions.
I am looking to be able to modify the appearance or retrieve information from my field.
For example, I'm looking to access my field so I can make it disabled once I click my anonymous action button.
I know that there is this kind of method but I cannot access my component as it is not linked to my action. It's impossible for me to do anything.
https://filamentphp.com/docs/3.x/forms/advanced#dynamic-fields-based-on-a-select-option
Or maybe there is a method to attach an anonymous action to a component?
https://filamentphp.com/docs/3.x/forms/actions#adding-anonymous-actions-to-a-form-without-attaching-them-to-a-component
Solution
Thank you Leandro, I was just looking for that!