Skip Navigation

[Resolved] Making a field required in Toolset Forms

This thread is resolved. Here is a description of the problem and solution.

Problem:
Types fields in Toolset Forms inherit whether they are required or not from their Types setting. Is it possible to make a field required in the Form, but not in the backend?

Solution:
Only with a custom solution, either adding some JS to the form to set the field in question to be required, or using the cred_form_validate hook to perform the validation on the server when the form is submitted.

Relevant Documentation:
https://toolset.com/documentation/programmer-reference/cred-api/#cred_form_validate

100% of people find this useful.

This support ticket is created 6 years, 6 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

This topic contains 2 replies, has 2 voices.

Last updated by Armando 6 years, 6 months ago.

Assisted by: Nigel.

Author
Posts
#915024
Firefox_Developer_Edition.png

I am trying to:
Set a field (radio) as required on the CRED front end side only. Not on the back end (Types Custom Field).

Link to a page where the issue can be seen:
Screen Shot

I expected to see:
Error Message

Instead, I got:
Nothing

I used:

 [cred_field field='job-post-length' value='' urlparam='' output='bootstrap' required="true"]

Thank you!

#915165

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Armando

There is no such attribute available on the cred_field shortcode: https://toolset.com/documentation/user-guides/cred-shortcodes/#cred_field

To make a field required in a Form that is not required in the backend you can

1. add a little JS to the Form to add the required attribute directly to the field yourself so that the browser validation will handle it automatically on the front-end, or
2. use the cred_form_validate hook to enforce the field requirement from the server (https://toolset.com/documentation/programmer-reference/cred-api/#cred_form_validate).

If you try one or the other and get stuck let me know and I'll help.

#915503

Thank you, I used the jQuery option.