Display the css classes on the form elements

Created on 28 March 2014, over 11 years ago
Updated 28 July 2025, 5 days ago

If you add this function to the module it should add the css class to the form as well as the display.

function field_formatter_class_field_widget_form_alter(&$element, &$form_state, $context) {
  $css_class = $form_state['field']['field_email_address'][LANGUAGE_NONE]['instance']['display']['default']['settings']['field_formatter_class'];
  if(!empty($css_class)) {
    if(empty($element['value']['#attributes'])) {
      $element['value']['#attributes'] = array();
    }
    if(empty($element['value']['#attributes']['classes'])) {
      $element['value']['#attributes'] = array();
    }

    $element['value']['#attributes']['class'][] = $css_class;
  }
}

The reason you would want to do this is incase you are using this module in conjunction with the entityform module.

✨ Feature request
Status

Closed: outdated

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States frob US

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024