validationRules with repeatable fields #259
-
Hi, Can someone succeed to make validation rules in the field definition like this ?
|
Beta Was this translation helpful? Give feedback.
Replies: 0 comments 6 replies
-
Hello @t-prod
If you want to define them generaly in the controller you should do When inside of the field you define them for the current field you are setting up, so something like: 'subfields' => [
[
'name' => 'quantity',
'label' => __('admin.product.crud.fields.cross-selling.quantity'),
'type' => 'number',
'attributes' => [
'step' => 1,
'min' => 0
],
'validationRules' => 'required:min:0',
'validationMessages' => ['required' => 'required msg', 'min' => 'min required']
],
], Backpack will automatically create the See docs here: https://backpackforlaravel.com/docs/5.x/crud-operation-create#validation-1 Let me know, |
Beta Was this translation helpful? Give feedback.
-
Sorry @pxpm I thought it was working but it's not the case. The validation rule on the subfield is ignored.
I set after addFields => $this->crud->setValidation(); Do you have same issue from your side ? Thanks for your help |
Beta Was this translation helpful? Give feedback.
That said @t-prod you can update in composer and can remove the
setValidation()
call in the end, as it is not needed anymore.Cheers
Thanks @tabacitu 🙏