You are here

function fel_fields_form_field_ui_field_edit_form_alter in Form element layout 7

Implements hook_form_FORM_ID_alter() for field_ui_field_edit_form().

File

modules/fel_fields/fel_fields.module, line 219
Field support for Form element layout (fel.module).

Code

function fel_fields_form_field_ui_field_edit_form_alter(&$form, &$form_state, $form_id) {

  // Minor justification of help text description to reflect that the position
  // of the description arent set in stone.
  $form['instance']['description']['#description'] = t('Instructions to present to the user for this field on the editing form.<br />Allowed HTML tags: @tags', array(
    '@tags' => _field_filter_xss_display_allowed_tags(),
  ));
  $form['instance']['settings']['description_display'] = array(
    '#type' => 'radios',
    '#title' => t("Help text position"),
    '#description' => t("Descriptions for form elements are usually rendered after the input element. Use this to override the default behavior."),
    // Let's eat our own dogfood, and give a user a preview of what this does.
    // It also serves as a sanity check for whether this property works or not.
    '#description_display' => 'before',
    '#options' => array(
      'before' => t("Before"),
      'after' => t("After"),
    ),
    '#default_value' => _fel_fields_default_position($form['#field'], $form['#instance']),
    '#states' => array(
      'visible' => array(
        ':input[name="instance[description]"]' => array(
          'empty' => FALSE,
        ),
      ),
    ),
  );

  // A bit intrusive, but stick label and description together with the
  // description_display setting.
  $form['instance']['element_layout'] = array(
    '#type' => 'fieldset',
    '#title' => t("Label and help text"),
    '#tree' => FALSE,
    '#weight' => -9,
  );
  $form['instance']['#pre_render'][] = 'fel_fields_widget_settings_pre_render';
}