Skip Navigation

[Resolved] How to hide label in checkbox?

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

Problem: I have a single checkbox field in a Form, and I would like to remove the label text that appears automatically next to the checkbox input.

Solution: The following code will remove the label text from this checkbox, on all Forms:

add_filter('cred_filter_field_before_add_to_form', 'remove_cb_label', 10, 2);
function remove_cb_label($field, $computed_values){
  if(isset($field['id']) && in_array($field['id'], array('your-field-slug'))){
    $field['title'] = '';
  }
  return $field;
}
This support ticket is created 6 years, 4 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
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 2 replies, has 2 voices.

Last updated by ivicaV 6 years, 4 months ago.

Assisted by: Christian Cox.

Author
Posts
#923485

Tell us what you are trying to do?

I am trying to set submission field and simple checkbox for CRED form. But when i insert field

[cred_field field='consent' post='posttype' value='' urlparam='' output='bootstrap']

I got field label on side. How to hide checkbox label here?

Is there any documentation that you are following?

Is there a similar example that we can see?

What is the link to your site?

chemgeneration.com/test

#923702

Hi, assuming this is a single checkbox and not a checkbox group, the only way to remove this label is to use a bit of custom code from our Forms API. Normally I would offer a simple CSS solution, but since the text is not the only element in its parent tag it is not possible to target it with CSS alone. You must add this snippet to your child theme's functions.php file:

add_filter('cred_filter_field_before_add_to_form', 'remove_cb_label', 10, 2);
function remove_cb_label($field, $computed_values){
  if(isset($field['id']) && in_array($field['id'], array('your-field-slug'))){
    $field['title'] = '';
  }
  return $field;
}

Replace "your-field-slug" with the slug of your checkbox field.

#923921

Wonderful. That did the trick. Thank you very much.