Replies: 4 comments 2 replies
-
I think we should handle this a lot better, yeah. The docs are on Git too, feel free to PR them. |
Beta Was this translation helpful? Give feedback.
-
It's not been documented yet because it's still a new feature and I wasn't 100% sure on the syntax, so was not willing to let people use it in case I wanted to make breaking changes. We should register the action automatically when it's passed to |
Beta Was this translation helpful? Give feedback.
-
#3276 has been merged, which brings several improvements to the form component actions DX
->registerActions([
- $action->getName() => $action,
+ $action,
]) And also, prefix & suffix actions are autoregistered: -registerActions([
- $prefixAction->getName() => $prefixAction,
- $suffixAction->getName() => $suffixAction,
-])
->prefixAction($prefixAction)
->suffixAction($suffixAction) |
Beta Was this translation helpful? Give feedback.
-
Is still this solution viable ? I cannot manage it to work :-( . I want to add an action button on form to calc field. |
Beta Was this translation helpful? Give feedback.
-
TextInput component SuffixAction
I was having a really hard time implementing the
suffixAction
feature for the TextInput component on Filament so I did some digging...Here's what I found and how to use it. (This should be on the documentation)
The Problem
Say we have this sample code to get us started on the same page...
So now, you want to add
->suffixAction()
into it so that the user would be able to generate new codes if they wanted...for some random client nonsense reason... so you added it...
That would cause an error... and you'll get lost on the documentation just to find a fix...
The error...
Typed property Filament\Forms\Components\Actions\Action::$component must not be accessed before initialization
so how should we fix this?
The Solution
Register the action...
How? Well first we need to store the action into a variable...
Then... we use
->registerActions()
... this method accepts an array of[actionName => actionObject]
Remember...
generateNewCode
is our action-name... because it is what put intoAction::make({name})
...How I found out about this?
I dived into the source-code, it's a very good way to understand the ins-&-out of a framework...
basically...
BelongsToSelect
has thiscreateOptionForm
method, which automatically creates the action for you and registers it to the select component then add it as a suffix...How Filament can improve from this?
it should document
registerActions
andsuffixAction
and also, when using
suffixAction
it should automatically registers the action.That's it, thanks for reading...
Beta Was this translation helpful? Give feedback.
All reactions