This support ticket is created Il y a 4 années et 11 mois. 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.
Aucun de nos assistants n'est disponible aujourd'hui sur le forum Jeu d'outils. Veuillez créer un ticket, et nous nous le traiterons dès notre prochaine connexion. Merci de votre compréhension.
It ought to be simple but I'm struggling with using a single checkbox as a CRED field.
I've created the field with settings per image. When the form is viewed on the frontend, I expected to see 'Box is unchecked' when the checkbox isn't selected and 'Box is checked' when the checkbox is selected but the text displayed is the custom field name (whether checkbox is selected or not).
Hello. Thank you for contacting the Toolset support.
Do you mean that the 'Box is unchecked' value should be displayed when you load your form?
Actually, "Value to show" section applied on the frontend where you will have a choice that either you will be able to display the value from the database or you can configure customized values for checked and unchecked states of the checkbox.
If you think that the configured customized values for checked and unchecked states should be displayed on the add/edit post form that is not true, its will offer you a normal HTML checkbox where either you can check or uncheck it.
I hope I made it clear and if I missed understanding your question, please feel free to clarify.
If you think that the configured customized values for checked and unchecked states should be displayed on the add/edit post form that is not true
I think the configured customised values should be displayed when the create/edit form is displayed on the frontend. What's the point of entering customised values otherwise???
I think the configured customised values should be displayed when the create/edit form is displayed on the frontend. What's the point of entering customized values otherwise???
==>
The customized values will be in action when you will use the Types shortcode to display that field on the content template or post body or within the view's loop etc..etc..
Having said that it will have an effect when you try to display the field value on the frontend. It will not have any effect with your add/edit form while displaying that field as an form input field.
To change the text of the checkbox - you should be able to change it by modifying the value of the 'Field name' field of your checkbox that will you see while you edit your checkbox field at top of that field box.
If you want to change the checkbox label dynamically without editing your custom field from custom field group then you should use the Tooslet Form's API hook: cred_filter_field_before_add_to_form
add_filter('cred_filter_field_before_add_to_form', 'func_change_form_field_value', 10, 1);
function func_change_form_field_value($field){
$field_slugs = array('your-checkbox-field-slug');
if(in_array($field['id'],$field_slugs)){
$field['title'] = "my checkbox title";
}
return $field;
}
where:
- Pleaes change your-checkbox-field-slug and my checkbox title