Skip Navigation

[Resolved] Mandatory check box

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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 8 replies, has 2 voices.

Last updated by YounesZ5625 4 weeks, 1 day ago.

Assisted by: Minesh.

Author
Posts
#2689689

I added the following code to make the checkbox mandatory but I'm having some issues
1) The form does not bring the error message I wrote in the code
2) The file the user uploaded flies and a new file must be uploaded again, which also creates an error message in the file upload field because it is a mandatory field
3) I can't find how to put an asterisk in required fields so the user knows the checkbox is a required field
add_filter( 'cred_form_validate', 'tssnippet_at_least_one_checkbox_validation', 10, 2);
function tssnippet_at_least_one_checkbox_validation( $field_data, $form_data ) {

$target_forms = array( 1394 );
$target_field_slug = 'web-od';

if ( ! in_array( $form_data['id'], $target_forms ) ) {
return $field_data;
}

// $field_data contains value and error fields
list( $fields, $errors ) = $field_data;

if ( ! isset( $fields[ 'wpcf-' . $target_field_slug ]['value'][0] ) ) {
$errors[ $target_field_slug ] = 'At least one checkbox is required';
}

return array ($fields, $errors);
}

Thank you
Younes

#2689725

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

You can add asterisk symbol with your form field's associated label. You may try to edit the form in "Expert Mode" if required:
- https://toolset.com/course-lesson/styling-front-end-forms/#how-to-style-front-end-forms

I would like to know - you have checkbox field or checkboxes field?

In addition to that - Could you please send me debug information that will help us to investigate your issue.
=> https://toolset.com/faq/provide-debug-information-faster-support/

#2689742

As for putting * I remember seeing in the past an option to set fields that must be * without having to write it in the label, but I can't find that option now. Is there no such possibility?
(I'm using the Astra theme)
And regarding 2) I didn't explain well and I will explain again the form is fine only because you have to mark the checkboxes, so if you don't mark then the form will not be sent and that's great, the only problem is that the file that the user uploads flies and is not saved like all the other fields that what he entered is saved! So he gets an error message about the file upload field, which is a mandatory field, and the check box he didn't fill in doesn't have a mandatory field message, so the user doesn't understand why it wasn't sent

{"core":{"Wordpress":{"Multisite":"No","SiteURL":"https:\/\/www.abri.co.il","HomeURL":"https:\/\/www.abri.co.il","Version":"6.4.3","PermalinkStructure":"\/%year%\/%monthnum%\/%day%\/%postname%\/","PostTypes":"post, page, attachment, revision, nav_menu_item, custom_css, customize_changeset, oembed_cache, user_request, wp_block, wp_template, wp_template_part, wp_global_styles, wp_navigation, cred-form, cred-user-form, wp-types-group, wp-types-user-group, wp-types-term-group, view, view-template, yonas, mahasik, kesher, wpa-helper, cred_rel_form","PostSatus":"publish, future, draft, pending, private, trash, auto-draft, inherit, request-pending, request-confirmed, request-failed, request-completed, hidden"},"Server":{"jQueryVersion":"3.7.1","PHPVersion":"8.2.15","MySQLVersion":"10.4.32","ServerSoftware":"Apache\/2"},"PHP":{"MemoryLimit":"512M","UploadMax":"64M","PostMax":"64M","TimeLimit":"300","MaxInputVars":"1000"}},"plugins":{"active_plugins":{"cred-frontend-editor\/plugin.php":{"Name":"Toolset Forms","PluginURI":"https:\/\/toolset.com\/home\/toolset-components\/?utm_source=plugin\u0026utm_medium=gui\u0026utm_campaign=forms#forms","Version":"2.6.20","Author":"OnTheGoSystems","AuthorURI":"http:\/\/www.onthegosystems.com\/","TextDomain":"cred-frontend-editor","DomainPath":"","Network":false,"RequiresWP":"","RequiresPHP":"","UpdateURI":"","Title":"Toolset Forms","AuthorName":"OnTheGoSystems"},"peters-login-redirect\/wplogin_redirect.php":{"Name":"LoginWP (Formerly Peter\u0027s Login Redirect)","PluginURI":"https:\/\/loginwp.com","Version":"3.0.8.5","Author":"LoginWP Team","AuthorURI":"https:\/\/loginwp.com","TextDomain":"peters-login-redirect","DomainPath":"\/languages","Network":false,"RequiresWP":"","RequiresPHP":"","UpdateURI":"","Title":"LoginWP (Formerly Peter\u0027s Login Redirect)","AuthorName":"LoginWP Team"},"toolset-blocks\/wp-views.php":{"Name":"Toolset Blocks","PluginURI":"https:\/\/toolset.com\/?utm_source=viewsplugin\u0026utm_campaign=views\u0026utm_medium=plugins-list-full-version\u0026utm_term=Visit plugin site","Version":"1.6.14","Author":"OnTheGoSystems","AuthorURI":"https:\/\/toolset.com","TextDomain":"toolset-blocks","DomainPath":"","Network":false,"RequiresWP":"","RequiresPHP":"","UpdateURI":"","Title":"Toolset Blocks","AuthorName":"OnTheGoSystems"},"types-access\/types-access.php":{"Name":"Toolset Access","PluginURI":"http:\/\/toolset.com\/home\/types-access\/?utm_source=accessplugin\u0026utm_campaign=access\u0026utm_medium=release-notes-plugins-list\u0026utm_term=Visit plugin site","Version":"2.9.0","Author":"OnTheGoSystems","AuthorURI":"http:\/\/www.onthegosystems.com\/","TextDomain":"types-access","DomainPath":"","Network":false,"RequiresWP":"","RequiresPHP":"","UpdateURI":"","Title":"Toolset Access","AuthorName":"OnTheGoSystems"},"types\/wpcf.php":{"Name":"Toolset Types","PluginURI":"https:\/\/toolset.com\/?utm_source=typesplugin\u0026utm_campaign=types\u0026utm_medium=plugins-list-full-version\u0026utm_term=Visit plugin site","Version":"3.5.2","Author":"OnTheGoSystems","AuthorURI":"http:\/\/www.onthegosystems.com","TextDomain":"types","DomainPath":"","Network":false,"RequiresWP":"","RequiresPHP":"","UpdateURI":"","Title":"Toolset Types","AuthorName":"OnTheGoSystems"}},"mu_plugins":[],"dropins":[]},"theme":{"Name":"Astra","ThemeURI":null,"Author":"\u003Ca href=\u0022https:\/\/wpastra.com\/about\/?utm_source=theme_preview\u0026#038;utm_medium=author_link\u0026#038;utm_campaign=astra_theme\u0022\u003Eכוח סיעור מוחות\u003C\/a\u003E","AuthorURI":null,"Template":"astra","Version":"4.6.7","TextDomain":null,"DomainPath":null},"extra-debug":{"access":{"rules":[],"settings":{"types":{"post":{"mode":"permissions","permissions":{"publish":{"roles":["administrator"]},"delete_any":{"roles":["administrator"]},"edit_any":{"roles":["administrator"]},"delete_own":{"roles":["administrator"]},"edit_own":{"roles":["administrator"]},"read_private":{"roles":["administrator"]},"read":{"roles":["administrator"]}}},"page":{"mode":"permissions","permissions":{"publish":{"roles":["administrator"]},"delete_any":{"roles":["administrator"]},"edit_any":{"roles":["administrator"]},"delete_own":{"roles":["administrator"]},"edit_own":{"roles":["administrator"]},"read_private":{"roles":["administrator"]},"read":{"roles":["administrator"]}}},"attachment":{"mode":"not_managed"},"oembed_cache":{"mode":"not_managed"},"user_request":{"mode":"not_managed"},"wp_template":{"mode":"not_managed"},"wp_template_part":{"mode":"not_managed"},"wp_global_styles":{"mode":"not_managed"},"wp_navigation":{"mode":"not_managed"},"yonas":{"mode":"permissions","permissions":{"publish":{"roles":["administrator"]},"delete_any":{"roles":["administrator"]},"edit_any":{"roles":["administrator"]},"delete_own":{"roles":["administrator"]},"edit_own":{"roles":["administrator"]},"read_private":{"roles":["administrator"]},"read":{"roles":["administrator"]}}},"wpcf-custom-group-58d4b338c51616aeeb9ca0595dd0dc40":{"permissions":{"delete_any":{"roles":["administrator"]},"edit_any":{"roles":["administrator"]},"read":{"roles":["administrator"]}},"mode":"not_managed","title":"מעסיקים מחוברים"},"0":{"mode":"not_managed"},"popup":{"mode":"not_managed"},"popup_theme":{"mode":"not_managed"},"_custom_read_errors":{"wpcf-custom-group-58d4b338c51616aeeb9ca0595dd0dc40":{"permissions":{"read":{"d79ed7aad79bd7a0d7aa":"error_ct","guest":"error_ct"}}},"wpcf-custom-group-6eef7103705f639dfd34cf90d00f309c":{"permissions":{"read":{"d79ed7a2d7a1d799d7a7":"error_ct","guest":"error_ct"}}}},"_custom_read_errors_value":{"wpcf-custom-group-58d4b338c51616aeeb9ca0595dd0dc40":{"permissions":{"read":{"d79ed7aad79bd7a0d7aa":"1359","guest":"1359"}}},"wpcf-custom-group-6eef7103705f639dfd34cf90d00f309c":{"permissions":{"read":{"d79ed7a2d7a1d799d7a7":"1328","guest":"1328"}}}},"wpcf-custom-group-6eef7103705f639dfd34cf90d00f309c":{"permissions":{"delete_any":{"roles":["administrator"]},"edit_any":{"roles":["administrator"]},"read":{"roles":["administrator"]}},"mode":"not_managed","title":"מתכנתים מחוברים"},"mahasik":{"mode":"not_managed"},"kesher":{"mode":"not_managed"},"wpcf-custom-group-ad3fbc4448a7b7bff576cb83d97a8115":{"permissions":{"delete_any":{"roles":["administrator"]},"edit_any":{"roles":["administrator"]},"read":{"roles":["administrator"]}},"mode":"not_managed","title":"משתמשים לא מחוברים"}},"tax":[],"third_party":{"__CRED_CRED_USER":{"__CRED_CRED_USER_GROUP":{"permissions":{"use_any_attachment_with_cred_user_forms":{"roles":["administrator","editor","author"]},"create_users_with_cred_2404":{"roles":["administrator","d79ed7a2d7a1d799d7a7","d79ed7aad79bd7a0d7aa","subscriber","guest"]},"create_users_with_cred_1277":{"roles":["administrator","d79ed7a2d7a1d799d7a7","d79ed7aad79bd7a0d7aa","subscriber","guest"]},"create_users_with_cred_2406":{"roles":["administrator","d79ed7a2d7a1d799d7a7","d79ed7aad79bd7a0d7aa","subscriber","guest"]},"create_users_with_cred_1353":{"roles":["administrator","d79ed7a2d7a1d799d7a7","d79ed7aad79bd7a0d7aa","subscriber","guest"]}},"mode":"permissions"}},"__CRED_CRED":{"__CRED_CRED_GROUP":{"permissions":{"use_any_attachment_with_cred_post_forms":{"roles":["administrator","editor","author"]},"delete_other_posts_with_cred":{"roles":["administrator","editor","author"]},"delete_own_posts_with_cred":{"roles":["administrator","editor","author","contributor","d79ed7a2d7a1d799d7a7","d79ed7aad79bd7a0d7aa"]},"edit_other_posts_with_cred_2175":{"roles":["administrator","editor","author"]},"edit_own_posts_with_cred_2175":{"roles":["administrator","editor","author","d79ed7a2d7a1d799d7a7","d79ed7aad79bd7a0d7aa"]},"create_posts_with_cred_1394":{"roles":["administrator","editor","author","contributor","d79ed7a2d7a1d799d7a7","d79ed7aad79bd7a0d7aa","subscriber","guest"]},"create_posts_with_cred_2188":{"roles":["administrator","editor","author"]},"create_posts_with_cred_1509":{"roles":["administrator","editor","author","contributor","d79ed7a2d7a1d799d7a7","d79ed7aad79bd7a0d7aa","subscriber","guest"]}},"mode":"permissions"}},"__CRED_CRED_REL":{"__CRED_CRED_REL_GROUP":{"permissions":{"use_any_attachment_with_cred_rel_forms":{"roles":["administrator","editor","author","contributor","d79ed7a2d7a1d799d7a7","d79ed7aad79bd7a0d7aa"]}},"mode":"permissions"}}}}},"types":{"add_resized_images_to_library":0,"images_remote":0,"images_remote_cache_time":"36","help_box":"all","hide_standard_custom_fields_metabox":"show","postmeta_unfiltered_html":"on","usermeta_unfiltered_html":"on"},"CRED":{"wizard":1,"cache_notice":1,"export_settings":1,"export_custom_fields":1,"autogeneration_email":{"subject":"Welcome new user","body":"[username]Your username is: %cuf_username%[\/username]\\n[nickname]Your nickname is: %cuf_nickname%[\/nickname]\\n[password]Your password is: %cuf_password%[\/password]"},"dont_load_cred_css":1},"views":{"views_template_loop_blog":0,"wpv_bootstrap_version":1,"wpv_custom_conditional_functions":["u_post_count"],"wpv_custom_inner_shortcodes":[],"wpv_debug_mode":"","wpv_debug_mode_type":"compact","wpv_map_plugin":0,"wpv_show_hidden_fields":"","wpv_saved_auto_detected_framework":"","wpv_codemirror_autoresize":"","wpv_enable_pagination_manage_history":true,"wpv_enable_parametric_search_manage_history":true,"support_spaces_in_meta_filters":0,"allow_views_wp_widgets_in_elementor":0,"default_user_editor":"gutenberg","default_wpa_editor":"gutenberg","manage_meta_transient_method":"cron","editing_experience":"blocks","disable_theme_settings":0,"views_template_conditions_for_yonas":[],"view_taxonomy_loop_category":331,"views_template_for_yonas":586,"view_cpt_yonas":"2323"},"installer":{"version":"3.1.3","repositories":{"wpml":{"api-url":"https:\/\/api.wpml.org\/","bucket-url":"not assigned","subscription":"","last-successful-subscription-fetch":"none"},"toolset":{"api-url":"https:\/\/api.toolset.com\/","bucket-url":"https:\/\/wptypes.s3.amazonaws.com\/toolset-bucket-8.json","subscription":{"key":"ZJmTdKcC7R","key_type":0,"data":{"subscription_type":7526,"expires":"2025-01-18","status":"1","notes":"","order_id":"2678873","hasAutoRenewal":true},"registered_by":1,"site_url":"https:\/\/www.dvorid18.ereznet.com"},"last-successful-subscription-fetch":"2024-02-28 10:01:56"}},"instances":{"\/home\/dvorid18\/domains\/abri.co.il\/public_html\/wp-content\/plugins\/types\/vendor\/otgs\/installer\/installer.php":{"bootfile":"\/home\/dvorid18\/domains\/abri.co.il\/public_html\/wp-content\/plugins\/types\/vendor\/otgs\/installer\/installer.php","version":"3.1.3","args":{"plugins_install_tab":"1","repositories_include":["toolset","wpml"],"site_key_nags":[{"repository_id":"toolset","product_name":"Toolset"}]},"delegated":true}}}}}

#2689760

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

As for putting * I remember seeing in the past an option to set fields that must be * without having to write it in the label, but I can't find that option now. Is there no such possibility?
(I'm using the Astra theme)
===>
You can make the field required or not from the custom field group where you added the custom field.

Can you please share problem URL where the form is added as well as admin access details and let me check what's going wrong with your setup.

If its required to access the form using frontend user - please share frontend user access details including admin user.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#2689886

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

That is totally different issue. I urge you to create a new ticket with every new question you may have in future. This will help other users searching on the forum as well as help us to write correct problem resolution summery.

Can you please tell me on what page you have added the multi-step form? Can you please share link of that page?

#2689888

hidden link

#2689916

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

The issue is - as per the solution shared with the reference ticket you shared:
- https://toolset.com/forums/topic/how-to-create-a-multi-step-form-using-toolset/

The following mentioned settings are required to setup multistep form:

All forms should be set not to use ajax, and should redirect somewhere upon submission (e.g. choose Display the post). That is required for the custom code which overrides the redirect to run; it needs something to override. The final form can use whichever setting is appropriate.

So with your form:
- hidden link

I've selected the option "Display the post" with form setting "After visitors submit this form:".

Can you please confirm it works as expected now.

#2689947

Thanks
It works great
I checked the previous issue I sent you that the file was deleted
And it only happens if I make a mandatory field with a custom code, (and not what is built into the system) then the form requires this field, but it does not save the uploaded files
So now it's not a problem for me because the fields are in two forms
I close the ticket
But I would appreciate it if you could confirm that this should indeed be the case, because I'm not an expert, I just saw it in the tests I did, so I divided the forms in such a way that I wouldn't have a problem
Best regards and much appreciated
Younes

#2689988

Sorry! I see it only works for me if I'm logged in as an administrator
But another user who goes to step 2 receives a message that the page is not found

#2690192

My mistake in access control settings
that the user did not have the option to edit his posts
Thanks
Younes

YounesZ5625 confirmed that the issue was resolved on 2024-03-31 07:49:14.
This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.