Filling data in custom forms on a custom page does not work
I am trying to have two forms on a custom page for a resource. Neither of forms is attached to the model.
I am unable to populate the form with data. It just doesn't do anything. Here's what I've done:
I've checked, when method is executed,
$this->record
is populated, if I do dd($form)
in that method, it seems form has the details.
But when page is rendered, the details are not populated.
What am I doing wrong?Solution:Jump to solution
Hmm. All that looks ok. But you’re missing the statePath() on each form. Make sure you haven’t missed any of the steps here: https://filamentphp.com/docs/3.x/forms/adding-a-form-to-a-livewire-component#using-multiple-forms
8 Replies
Make sure you are calling the fill() method on both forms in mount()
how can I do that in
mount()
?
both manualPaymentForm()
and stripePaymentForm()
methods take Form
object, how do I get them in mount()
method? 🤔
For the record, this inside mount()
method:
...did not work.Just used two forms instead of one...
How are you outputting them in the blade file?
Solution
Hmm. All that looks ok. But you’re missing the statePath() on each form. Make sure you haven’t missed any of the steps here: https://filamentphp.com/docs/3.x/forms/adding-a-form-to-a-livewire-component#using-multiple-forms
Ok, figured this one out. Turns out that, I was missing properties for the forms, so:
Then, the
statePath()
had to be set to match their names, once that was added, forms are prepopulated with data now 👍