I have a form in which if certain options are selected the form is completed before reaching the final wizard. The issue i’m facing is that although i am removing the wizards to allow the user to submit instead of pressing Next it blocks due to required fields later in the form needing to be populated. Is there a way to unrequire all required fields on the form at once or does it have to be done individually? Thanks
You can get a collection of all the fields using fd.fields()method. So, to make all fields optional you can use the following snippet:
for (const field of fd.fields()) {
field.required = false;
}
You could also filter fields by css selectors. For example, this snippet filters all fields inside a Grid container with a custom class of guest-info, and makes them optional:
for (const field of fd.fields()) {
if (field.$el.matches(".guest-info *")) {
field.required = false;
}
}
But I'd say storing an array of field names would be less prone to unexpected errors as long as you remember to update it.