2

How can I highlight the checkbox boxes when be validated a CCK field? (CCK 2.9). Data is validated correctly, and message is displayed correctly in the head of the form, but the checkboxes does not appear highlighted.

<?php    
$quantity_options = count($form_state['values']['field_checkboxes']);
if ($quantity_options > 2) {
form_set_error('field_checkboxes', 'message.');
}
?>
4

Have a look if the class error has been added to your <input>. It has on my side, it's the CSS that does not highlight the elements properly.

You can either adjust your stylesheet for .form-item input.error or you can use a piece of jQuery to make the parent of the radios styleable, such as

$('.form-radios:not(.error):has(.form-item input.error)').addClass('error');

Another option would be to add the appropriate class via the Drupal's theming system (theme_optionwidgets_buttons()).

  • thanks for your answer. the class error is in the checkbox. So I think that the problem is related with compatibility of CSS with checkboxes. for example (sucessfuly): .form-item input[type="checkbox"].error{ outline: 2px solid red; } so can be controlled using respective rules according crossbrowsers tips. – cigotete Aug 8 '11 at 18:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.