Fatih Durmaz
afterStateUpdated() function does not work when hidden() is true
Toggle::make('kismi_teklife_acik_mi')
->live()
->requiredWith('kisim_sayisi')
->inline(false)
->afterStateUpdated(function (Get $get, Set $set) {
if (($get('kismi_teklife_acik_mi') == false)) {
$set('kisim_sayisi', null);
}
})
->label('İhale Kısmi Teklife Açık Mı?'),
TextInput::make('kisim_sayisi')
->label('Kısım Sayısı')
->requiredWith('kismi_teklife_acik_mi')
->numeric()
->validationAttribute('Kısım Sayısı')
->hidden(
fn (Get $get): bool => !$get('kismi_teklife_acik_mi')
),
Hello, I want to empty the kisim_sayisi field when the kismi_teklife_acik_mi field is closed. If it is visible, it works, but if it is not visible, it does not assign null. In short, afterStateUpdated() does not work when hidden() is true.
5 replies
custom form field without database just form
I want to make changes within a form using a field that is not in the database. Based on the toggle value, I will hide or show another field, but the toggle itself will not be in the database.
Toggle::make('kismi_teklif') // not in database just form
->live()
->onColor('success')
->offColor('danger')
->label('İhale Kısmi Teklife Açık Mı?'),
TextInput::make('kisim_sayisi')
->label('Kısım Sayısı')
->numeric()
->visible(fn (Get $get) => $get('kismi_teklif') === true),
3 replies