Form field not updating with reactive()

Hello everybody, I built the following form and I need that when the user sets "turn_on_opening" to true, the turn_on_at field takes the value of the shop_opening_time. The callback is working but the data is not put inside the field. How can I solve this issue?Thank you...
2 Replies
Gianmarco Varrone
public function mount($relayNumber, $controlUnit) { $this->relayNumber = $relayNumber; $this->controlUnit = $controlUnit; $pointOfSale = PointOfSale::find($controlUnit->point_of_sale_id); $this->shop_opening_time = $pointOfSale->opening_time; $this->shop_closing_time = $pointOfSale->closing_time; $relays = $this->controlUnit->relays()->get(); } protected function getFormSchema() : array { return[ TextInput::make("name")->required()->label("Identificatore relay"), TimePicker::make('turn_on_at')->label("Orario accensione relay")->reactive(), Checkbox::make("turn_on_opening") ->label("Accendi questo interruttore all'apertura del negozio") ->inline() ->reactive() ->afterStateUpdated(fn ($state, callable $set)=> $set("turn_on_at", $this->shop_opening_time)), Checkbox::make("turn_on_closing")->label("Accendi questo interruttore alla chiusura del negozio")->inline(), TimePicker::make('turn_off_at')->label("Orario spegnimento relay"), Checkbox::make("turn_off_opening")->label("Spegni questo interruttore all'apertura del negozio")->inline(), Checkbox::make("turn_off_closing")->label("Spegni questo interruttore alla chiusura del negozio")->inline(), ]; } Also, this form is being used in a foreach loop, could this be the reson? Is there a way to pass an unique identifier to the form?
toeknee
toeknee2y ago
You are not mounting the form, pleae ensure you mount it with: $this->form->fill('all the data here'); No need to use the public properties instead, pass it into the mount method as an array for the properties to be set.

Did you find this page helpful?