You are here

function commons_bw_form_field_ui_field_edit_form_alter in Drupal Commons 7.3

Implements hook_form_FORM_ID_alter().

Add a setting to group content fields, to determine whether they will be displayed on the mini node form of the browsing widget.

File

modules/commons/commons_bw/commons_bw.module, line 111

Code

function commons_bw_form_field_ui_field_edit_form_alter(&$form, &$form_state, $form_id) {
  if (!og_is_group_content_type($form['instance']['entity_type']['#value'], $form['instance']['bundle']['#value'])) {
    return;
  }

  // See if we're building for the first time, or getting pre-saved values.
  $field_name = $form['#field']['field_name'];
  if (!empty($form_state['field'][$field_name][LANGUAGE_NONE]['instance']['display_in_partial_form'])) {
    $display_default = $form_state['field'][$field_name][LANGUAGE_NONE]['instance']['display_in_partial_form'];
  }
  else {
    if (isset($form_state['build_info']['args'][0]['display_in_partial_form'])) {
      $display_default = $form_state['build_info']['args'][0]['display_in_partial_form'];
    }
    else {
      $display_default = FALSE;
    }
  }
  $form['instance']['display_in_partial_form'] = array(
    '#type' => 'checkbox',
    '#title' => t('Display in the browsing widget mini-form'),
    '#default_value' => $display_default,
  );
}