You are here

function bricks_field_widget_form_alter in Bricks​ 7.4

Same name and namespace in other branches
  1. 7.5 bricks.module \bricks_field_widget_form_alter()

Implements hook_field_widget_form_alter().

File

./bricks.module, line 148

Code

function bricks_field_widget_form_alter(&$element, &$form_state, $context) {
  $field = $context['field'];
  if ($field['type'] == 'entityreference' && $field['field_name'] == 'field_body') {
    $element['target_id']['#size'] = 10;
    if (isset($element['entityreference_live_preview'])) {
      $element['entityreference_live_preview']['#weight'] = -1;
    }
    $item = isset($context['items'][$context['delta']]) ? $context['items'][$context['delta']] : NULL;
    $element['options'] = array(
      '#tree' => 'true',
      '#weight' => 11,
      'classes' => array(
        '#type' => 'textfield',
        '#attributes' => array(
          'placeholder' => t('Additional CSS classes'),
        ),
        '#default_value' => !empty($item['options']['classes']) ? $item['options']['classes'] : '',
      ),
    );
  }
}