I would like to do the following:
- allow users to create and edit a custom post type
- allow users to save the incomplete post and come back to it.
- the custom post type will be quite long so they may need multiple sessions to complete it
The problem is with the required fields. There will be required fields but having those required fields will prevent the user from saving a partially completed form without filling those fields.
What I would like to do:
- have required fields
- but they don't get validated when the user saves a partially completed version of the form (maybe it has 'draft' status?)
- and when the user is ready to submit the post, then the validation would check to make sure everything is completed. If the post passes validation then it gets submitted.
I haven't found something in the documentation that would support this.
Hello. Thank you for contacting the Toolset support.
In that case - you will require to follow the multi-step form that is actually not a Toolset feature but workaround that should help you to resolve your issue.
Thanks for getting back to me and for offering this solution. I see how this could be an answer but I actually need something different.
The form I'm building will be long and complicated. The person filling it out may need to come back to it multiple times, filling different fields before they can submit it. So they can't complete one part at a time as suggested with the multi-step form because they will have missing content throughout the form.
So.. can I set required fields but then suppress the validation or at least ignore the validation, when the user SAVES A DRAFT? And only follow the validation when they SUBMIT THE FORM?
Now, it's on you, if you dont set the validation rules with the custom field group where you manage the custom fields and only validate when you submit the form using hook: "cred_form_validate"
Thanks for this answer. After reading your notes and following your links, I found a couple of other support posts that discuss aspects of this problem:
I have a question about the form hooks. Are they applied before the form is displayed? Or can they be applied when submitting the form? It seems to me that they won't work if they are applied BEFORE. Those form hooks only provide a solution if they can be applied AFTER the form is submitted.
Please confirm.
In other words, is it possible to:
- disable validation when user hits 'Save'
- leave validation enabled when user hits 'Send and Close'
I have a question about the form hooks. Are they applied before the form is displayed? Or can they be applied when submitting the form? It seems to me that they won't work if they are applied BEFORE. Those form hooks only provide a solution if they can be applied AFTER the form is submitted.
====>
The Toolset form hook as the name suggested "cred_filter_field_before_add_to_form" - it will run before the field is added to the form.
=> https://toolset.com/documentation/programmer-reference/cred-api/#cred_filter_field_before_add_to_form
Description
This filter enters into action before each field is added to a Form on the front-end of the site, and gives users the ability to modify several field attributes. Attributes vary by custom field type, so the examples here are generalized.
So lets say you set XX field required from the custom field group that is set to display with post type "Book", later you created the form to add new book item so by default the XX field is required but you can use the above hook "cred_filter_field_before_add_to_form" to remove the required validation.
I think this is the thing you want.
If you share real life scenario with your requirement and problem URL where you want to add the form as well as what is the flow of your site to add/edit the multi-step form and at what point you want to validate the things and at what point you want to remove the validation then I will be able to guide you in the right direction.