Form Actions\Action everything null
Brain fart? Why is everything returning null or []. This is within a form schema()
18 Replies
I know you're on standalone, but in the edit page of a resource,
$record
is returning the record I'm editing and $get
is returning the other field I'm getting.
Not sure why the others aren't working...digging through resolveDefaultClosureDependencyForEvaluationByName
$form
doesn't appear to be an acceptable parameter so it'll just return an empty array. $data should return $this->getFormData()
...not sure why it's not.Well if there’s no form defined on the action then the action will not have form data.
Actions don’t natively inherit based on where they are registered and cached.
@awcodes even when it’s a form action within the actual form? The form is in a modal and launched from an EditRecord on a table
You have to mount the action with the data. $data will always be null if you don’t pass the data to it.
advice for the best way to fetch such info when its an action in an form in a modal launched by editrecord on a table? 😛
not having access to $get stinks. trying to do basically a note input section within the form that can easily be submitted by that internal form action without affecting the rest of the form
Maybe registering the action in the edit record action using
registerActions()
? (I think that’s the method name). That might give you access to the form???i think thats only available for a view component or infolist
You don’t need access to the form only the data on the livewire component.
Sorry…it’s registerModalActions(). But that might not work anyway.
I might not be totally wrapping my head around what you are trying to do, and this might not be the best way, but I was able to use
registerModalActions()
to register another action and in that first action, and then by dd($livewire)
inside action()
I had access to the the form data in the initial modal. Again, there might be an easiser wayThat gave you access to changes within the form like you would get with $get? I think it would only get it initial data. I will give it a try though.
@archilex ok, so i did but zero clue on how to now access that action within my
PropertyInquiry::getForm()
form schema or is it expected to use modalContant() and setup a form method and load the form and action within that view as if it was standalone livewire componet?Ah yes...sorry, I thought your form modal was a standalone livewire component where you could then render the action...I mean you could still do that, but there has to be a better way...hmmmm
Wait...can you not affix the action to a field??
Yes...if you can live with the button living at the end of an input field then this works:
I think i solved it actually
a bit more convoluted than it should be though
I guess you could even make a custom input that is really just an empty input so you can attach your action to it.
A custom input seems like a good way to go actually...
As long as it uses the suffixAction method it should work.
and then and then in the blade
lol
Hey if it works!!
Went ahead and did this:
And then you can resuse this wherever you want
That might not entirely work though...only getting the $current record, not updated fields...but you've got a working solution so I wont dig into this anymore.
so i ended up having to do the following on the action to get the current note being inputed in the form. Its a big cluster though and i dont like it and now i realized i cant easily have access to $set to null out that note input form after sending. Its not super hard to follow, but it shouldnt be this messy
im actually undoing it all. its just not maintaintable and easy to test. too many things for such a basic action. im simply just going to save the note on main save
an Action in a form should have full access to the form data
Take a look at my idea again...what I shared isn't working because I threw away all of the original view, but when you just use the suffixAction on a normal TextInput, you get access to both $get and $set. I just tried and it's working as expected. So I bet if you dig through the original text-input.blade.php file you'll be able to find the pieces that I removed that make this work with a custom Input. It's probably a $getState or something like that that needs to stay in there.
Again, this might not be what you are trying to do, but as a proof of concept, here's a demo video: