milkslices
milkslices
FFilament
Created by milkslices on 6/4/2024 in #❓┊help
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
#[On('element-clicked')]
public function onElementClicked(string $clickedElementText)
{
// I'm looking to update the 'input' field with the value of $clickedElementText
}

public function editAction(): Action
{
return Action::make('edit')
->fillForm([
'input' => 'Initial'
])
->form([
TextInput::make('input')
])
->action(function (array $data) {

});
}
#[On('element-clicked')]
public function onElementClicked(string $clickedElementText)
{
// I'm looking to update the 'input' field with the value of $clickedElementText
}

public function editAction(): Action
{
return Action::make('edit')
->fillForm([
'input' => 'Initial'
])
->form([
TextInput::make('input')
])
->action(function (array $data) {

});
}
5 replies