Programmatically change the values of a single Livewire component form action
Context
I'm working from a custom Livewire component.
What I'm looking for
My users can create 1 or more clickable text elements on the page.
When they click one, the form should show with one of the fields set to the value of the element they clicked.
Initial progress
I have a form action that templates the fields needed with initial defaults. I can mount this in my click event and have reference to what was clicked.
Current problem
I'm not sure how to programmatically change the value of certain form fields, and have this shown the next time the action is mounted?
Example
2 Replies
You inject the Set object to the action handler to set something on the form:
https://filamentphp.com/docs/3.x/forms/actions#form-component-action-utility-injection
I've added an example to make what I'm trying to do clearer as the form is defined on the action itself and shown within the modal that opens
Turns out the answer was relatively simple: