I have to create a form that allows to register a custom post type.
I need to create two form submission buttons, one that records if the required fields are not filled and a one that only records if the required fields are filled in.
How can I achieve this ?
Hi Olivier,
Thank you for contacting us and I'd be happy to assist.
When a Toolset Types field is set as required, in the field's setting ( req: https://toolset.com/documentation/user-guides/using-custom-fields/ ), that validation rule is automatically applied to it in the admin area ( post edit screen ) and also in the front-end Toolset Forms.
It is not possible to have two submit buttons in the same form or make the form ignore that required validation rule on-the-fly, but you can use a workaround that involves two separate forms.
First, you'll make sure that no fields are set as "required" from the field's own setting.
Then in your first form, you can include all those fields and it will be possible to submit the form without any validation.
In the second form, you'll also add all those fields, but for this form, you'll add validation rules to the fields that you'd like to be required, through either "cred_form_validate" hook ( ref: https://toolset.com/documentation/programmer-reference/cred-api/#cred_form_validate ) or through conditional form groups ( ref: https://toolset.com/documentation/user-guides/conditional-display-for-form-inputs/ ).
This way, the second form's submission won't be possible, unless the specified fields have been filled.
I hope this helps and please let me know if you need any further assistance around this.
regards,
Waqar
I need to display a single form with two buttons as on the capture. Is it possible to do that with your method?
Hi Olivier,
Thanks for writing back and for sharing the screenshot.
I'm afraid the two-button submit feature that is shown in your screenshot, is not supported by Toolset Forms, out-of-the-box and the workarounds that I've shared will also not work for this specific requirement.
This will require form customization, for which you can consider hiring a professional from our list of recommended contractors:
https://toolset.com/contractors/
regards,
Waqar