You'll need to use a server-side event (e.g. preCreate and preEdit in this case) to add a notEmpty validator to the correct field. You'll also need to know what the correct field is to be able to do that - I'm not sure what logic you are using to determine that though?
->on('preCreate', function ($editor) {
if (/* some condition */) {
$editor->field('field1')->validator( Validate::notEmpty() );
}
else {
$editor->field('field2')->validator( Validate::notEmpty() );
}
})
Obviously it needs the logic for the condition filled in, I don't know what you need for that, the field names and any other customisation you need, but that's the basic structure. Use similar for preEdit.
Replies
Use this event: https://editor.datatables.net/reference/event/initSubmit
And there is also an example on that page:
Hello rf1234,
I have looked at these examples, but it doesn't work for my scenario. I just want to disable "required" attribute with hidden fields.
Regards
Hi,
You'll need to use a server-side event (e.g.
preCreate
andpreEdit
in this case) to add anotEmpty
validator to the correct field. You'll also need to know what the correct field is to be able to do that - I'm not sure what logic you are using to determine that though?Allan
@rf1234 - Nice reference to Section 31
Hi Allan,
Could you please give me an example.
Thanks
Obviously it needs the logic for the condition filled in, I don't know what you need for that, the field names and any other customisation you need, but that's the basic structure. Use similar for
preEdit
.Allan