Repeater - strange behaviour

I am using repeater. I have a toggle field, when on, it adds the items to the repeater. If I try to reorder them with drag&drop, items are added again. If I reorder with the buttons, everything is fine. Is this a bug?
if($state) {
if(count($get('working_hours')) === 0) {
foreach (DayOfWeek::cases() as $index => $dayOfWeek) {
$set("working_hours.$index.day", CompanyHelper::company()->working_hours[$index]['day'] ?? null);
$set("working_hours.$index.start", CompanyHelper::company()->working_hours[$index]['start'] ?? null);
$set("working_hours.$index.end", CompanyHelper::company()->working_hours[$index]['end'] ?? null);
}
}
return;
}
if($state) {
if(count($get('working_hours')) === 0) {
foreach (DayOfWeek::cases() as $index => $dayOfWeek) {
$set("working_hours.$index.day", CompanyHelper::company()->working_hours[$index]['day'] ?? null);
$set("working_hours.$index.start", CompanyHelper::company()->working_hours[$index]['start'] ?? null);
$set("working_hours.$index.end", CompanyHelper::company()->working_hours[$index]['end'] ?? null);
}
}
return;
}
working_hours è il repeater
No description
No description
4 Replies
toeknee
toeknee2w ago
Is this in a custom form outside of a resource?
galli.roberto
galli.robertoOP2w ago
no, it's regular form
toeknee
toeknee6d ago
Can you provide the whole code please
galli.roberto
galli.robertoOP6d ago
I changes the way I use it, I don't have the code now, sorry
Want results from more Discord servers?
Add your server