control modal from blade file
I have a page where different types of users' information needs to be saved. There is only one action button that opens a modal containing a form that collects the users info, and save that into an array temporarily.
as soon as the array has got an item, there is my custom view that renders the data along with two buttons (update, and delete).
the delete function takes the index of the current item, and then removes the item from the array in case it is clicked.
Now the real questions comes here!
here is the update button
I would like to have a modal to open when this button is clicked. The modal should contain a form with some pre-filled data passed to it.
how can I implement the openModal function to open the modal and pass the needed data to it, so the modal can fill its form with the corresponding data.
I am new to filament, so if I am doing it wrong, let me know about the correct way of doing it.
4 Replies
to fill the form, you would use
$this->formName->fill([])
in openModal()
then you would dispatch the browser event to open the modal
but without more specific details about your modal and form i dont think i can help furtherlet me give details.
I have these public variables
And in mount function I have written this
And I have my getActions function like this
I have already specified a custom view
In my blade file at the very first part I have this part where it shows the content of the bill_item variable along with a delete and an update button.
As soon as I click update button it shows this modal to me which is on the same blade file.
coming back to the question
I have created a function that can be accessed in this blade file
I would like this function to open the modal for me, and shows a form inside itself for me with some prefilled data.
@Dan Harrin thanks for the reach-out, anyways 🙂
so what currently happens when you click the button
It only opens the modal. But what I want is something different. Plus, the modal currently does not have anything in it, except for some hardcoded lines.
Because there will be multiple items in bill_items, each of them will have an update button. When I click the update button, the editBillItem must be called to so that it pushes that specific item of the array in editData variable. So that I can prefill the form with that.
This is the reason why I would like the modal to be opened while editBillItem function is called.