When i make a form component reactive, it crashes
When the user changes the date in the picker, it crashes, and the form stops working:
48 Replies
where have you placed that DateTimePicker?
inside here:
And how have you rendered the page?
return view ('name of the view')->layout(layout::class)
wdym
Ok what are you using in the layout view ? i.e. do you have the primary div
yes, all wrapped in a div
ive discovered that also happens when i submit the form
I assume this is a custom livewire component and page outside of the filament panel?
i havent installed admin panel
only forms ,, notifications & tables
Ok, so you need to ensure livewire is loaded, ideally in the head before the forms and components are.
Also livewire components need to be wrapped i.e.
i said all is inside a div
You said, but your code showed otherwise. If providing snippets it's not helpful as it's a guessing game wihtout all the code as clearly you have a mistake somewhere.
in all other pages it works, livewire is loaded
Livewire can work loaded last and first, but that's not the issue the issue is the componetns are being triggered possibly before livewire is loaded.
why i clearly have a mistake? cant be a bug?
So it's best to load it first.
It is extremely unlikely to be a bug.
not the first time i found bugs in filamentphp
Ok, bye.
but yeah
what?
lol
We are here offering help for free, if you're just going to argue opposed to listening and checking/providing code as per the #❓┊help then we will focus our time on people looking for help. Your implementation sounds very standard and unlikely to be a bug.
and that is the weird thing. i checked my code and compared it with other forms i have, and i cant understand what is going on
i was just answering, not arguing opposed
messages are only messages, depends on u how u read them. didnt mean to be agressive or something
Have you use the datetimepicker in other views?
yes
but i think is something related when the component refreshes
as i did reactive there, when changing it, it refreshed. so then crashed
that is why then i said that when savig also crashes, cuz it refreshes the component
if something is unclear just let me know ill try to explain it better
But you are jsut using reactive to refresh correct?
im using reactive there to get the new date and change a components variable depending on the date chosen
Can we see the whole livewire component blade. Based on what you posted you form isn’t even inside the form tags. I’m thinking you are missing a tag somewhere that is breaking livewires dom diffing.
This could be because you are adjusting the public properties outside of the livewire form.
$this->isPublished
try:
$set('isPublished', true)
as an example
ill try that, but id like to change the public property of my livewire component, not to create a new field in the form
1 sec
The way livewire works is it registers the properties and mounts them, when they change outside it causes all sorts of issues as they don't match up with what has been registered as I understand it. so you would tend to set it, maybe traverse outside of the form:
$set('../isPublished', true)
is there a mount method?
yep
is an edit-only form, not create
okay i removed all other stuff not related to the error. i event only need a form field to make it crash.
Component:
view:
when i submit:
wdym inside the form tags?
ah i understand, u mean the html tags
>
no, i do have them, but for the example i wrote it fast. next time ill write it fine, without the ...
just did put ...
to say that i skip parts, but yeah that wasnt clear sorryI understood that. But you showed {{ $this->form }} above your opening form tag. 🙂
fack, sorry
let me edit it
anyways, for the new example im not using form, just button wireclick
can you share the layout code?
Based on what you’ve shown I’m not sure. Typically that error gets thrown due to dom diffing issue. Alpine is loosing track of the livewire component.
too big, what do u need to know about it?
if it is useful to u, in other views i have using same layout, forms & tables work just fine
If you put the picker in another form that is working, does it break.?
it doesnt
the datepicker is, lets say, the way i found the error
but not the error itself
here
if you dont want to declare all properties, you need to use
or
isPublished is not a property of the model
is just a boolean i created. the property would be publish_date
ill try that anyways
you have
TextInput::make('title)
but it isnt declared
you should do public string $title;
just did it. i added
public string $title;
. but im getting exact same error :/did you try it?
because if you have a title in the form, you should do this:
if you are passing all fields, you need to declare
or use $data
i added this:
now works!!!!
leandro, thanks!!!
and thanks y'all
appreciete ur time 🙏
Nice.. you can do this:
$this->form->fill($this->notice->toArray());
But you need to declare all properties
or forget it and use $datafinal code: