Skip Navigation

[Resolved] Single Checkbox CRED Field

This support ticket is created 4 years, 11 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
- 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 julieP 4 years, 11 months ago.

Assisted by: Minesh.

Author
Posts
#1417469
checkbox.JPG

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).

Have I misunderstood something? Is this expected?

#1417803

Minesh
Supporter

Languages: English (English )

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

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.

#1417991

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???

#1417995

Minesh
Supporter

Languages: English (English )

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

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.

#1418007

Ok - I get it now. It doesn't seem logical to me that the approach for checkboxes isn't the same as radio fields!

So how do I change the text shown next to the checkbox when the form is shown on the frontend please?

#1418029

Minesh
Supporter

Languages: English (English )

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

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.

#1418573

without changing the field name?

#1421097

Minesh
Supporter

Languages: English (English )

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

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

#1427121

My issue is resolved now. Thank you!