Form in livewire component empty data on create
I made this form as a livewire component, the idea was to generate dynamic forms that will change depending on what im receiving from an external api, and once the form fills send back the data to the api, but im having trouble extracting the data in my save function, the forms are generating well but each time i submit my form im getting an error that says that my circuit is null, i dont need to save this data in my database, i just need to access the data from the forms and send it back to the api. anyone knows how to fix it?
4 Replies
You've missed off the mount. Without a mount function running $this->form->fill() the data won't be passed back on submission.
i actually have the mount, i just cut the code because i didnt want to fill the post with a lot of images
ideally ou should be using code comments as per #✅┊rules
You are setting a form title try:
$record?->circuit;
failing that, provide the error shown.
Im sorry about the images instead of the for the code, i tried but discord complained because i was exceding the characters limit for non turbo users.
Im getting Attempt to read property "circuit" on null, more precisely on the public form function, but only when i submit my form, before that the form generates with all the fields that i get from the api
(i debugged the code and saw that the $record is null not only the circuit variable)
I tried generating my form in a separate function, calling that function in my mount method, saving the array in an instance variable and then call it in my form function, but that didnt even work with static forms.
well i actually solve it moving the api request to a separate function and calling the function in the mount method.
anyway, thank you very much Toeknee for having the time to check my post 😀