Simple repeater values not showing on edit
I'm sure I'm doing something wrong but I can't figure out what.
I have a simple repeater field for a JSON column called
times
(just a time value eg. 8:00 AM) . The Model casts this field as an array. I can create records and display the value of the times
column as a badge on my table, no problem there. But when I click edit. The repeater shows all the imputs but with no values in them
My repeater column definition
I appreciate all the help I can get.Solution:Jump to solution
More specifically, a non-native time picker issue. Removing
->native(false)
from the time picker field also works just fine, which will do fine for now22 Replies
Oh, and I've already ran
composer update
. My table builder package version is 3.0.53
here's the model
and the migration
Anyone around? this is actually holding me back a bitoh thank God!
Pretty sure the date / time pickers need a carbon instance to work properly.
Well, if that's the case, wouldn't it fail to show on a non-simple repeater?
Possibly. I do know that the simple repeater has a different underlying data structure though. So it’s probably just a matter of formatting the data in the right way with formatStateUsing()
Or the appropriate hydration method.
#awcodes-table-repeater could be a possible solution too if your having troubles with it.
Ok I'll try out your suggestions and come back with results. Do you mind if I @ you on this thread once I have something to share? If it works you won't hear from me again 😅
Sure. No worries. Feel free. Thank you for asking.
Ok, I can't do
modifyStateUsing
on the repeater field because a quick dd on the state reveals that is actually null (image 1)
Also, using modifyStateUsing
on the repeater itself reveals that the structure of the data is a flat array of string values. (image 2)
I might have to deep dive into the repeater code to figure out where are the values getting lost
If that doesn't work I'll move on to the table-repeater. I do feel the documentation is a bit misleading in this case.Oh, its a TimePicker issue. Using a TextImput works just fine!
Solution
More specifically, a non-native time picker issue. Removing
->native(false)
from the time picker field also works just fine, which will do fine for nowWas just about to say that. Lol. The js version is expecting a carbon instance.
Glad you got it working though.
right, and it can't figure it out from a JSON column. And I can't really cast the contents of a JSON column contents into a carbon instance
No but you could loop through the array and convert each item as a carbon instance. Probably overkill for the need though.
Oh, what I can do is move the JSON column to another table
and cast that as time
That’s even more unnecessary. Lol. But if it works for you, sure.
I'll think about it. It's for a simple Youtuve video example so a time picker would do just fine
not central to the subject
Could just loop through the state in afterStateHydrated() and set the component->state() as an array of carbon instances.
Hmm, that's a good idea. I'll try that
What ever works for you.
Ok marking as closed. Thanks for the help
No worries. Happy coding.