F
Filamentβ€’8mo ago
Alexandre

Conditional validation on field in a repeater

Hi all, I have some difficulties to run validation on fields in repeater fields... So, let me explain, my repeater is a "product". This product contains product-related fields (so far, so good). In this product, I want conditional fields. For example, we have a "key number" field which is required by default. However, this field should no longer be required if the user has checked the "lost card" field. Here are the fields concerned in the repeater:
Checkbox::make('no_card')
->label(...)
->nullable()
->live()
->columnSpanFull(),
Checkbox::make('no_card')
->label(...)
->nullable()
->live()
->columnSpanFull(),
And the second field :
TextInput::make('key_number')
->label(...)
->prefixIcon('heroicon-m-hashtag')
->requiredWithout('no_card'),
TextInput::make('key_number')
->label(...)
->prefixIcon('heroicon-m-hashtag')
->requiredWithout('no_card'),
When I submit the form, it's like the validation passed even if the checkbox is not checked. I tried also with requiredIf like that :
->requiredIf('no_card', false)
->requiredIf('no_card', false)
Did I miss something to use requiredWithout validation rule with a checkbox? Because with a textInput it's work... Thanks πŸ™‚
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server