You are here

function nd_add_fields in Node displays 6

Add fields to display overview form.

1 call to nd_add_fields()
nd_display_overview_form in includes/nd.display.inc
Menu callback; presents a listing of fields display settings for a content type.

File

includes/nd.display.inc, line 75
Display overview form.

Code

function nd_add_fields(&$form, $nd_display_settings) {
  $build_mode = $form['#build_mode'];
  $node_type = $form['#node_type'];
  $has_body = $form['#has_body'];

  // Get extra fields.
  $fields = nd_get_fields($node_type, $has_body, $build_mode);
  if (!empty($fields)) {
    foreach ($fields as $field => $value) {
      $form['#fields'][] = $field;
      $form[$field] = !empty($form[$form['#fields'][0]]) ? $form[$form['#fields'][0]] : nd_field_default_form_properties($build_mode);
      $form[$field]['human_name']['#value'] = $value['title'];
      $form[$field]['weight']['#default_value'] = nd_default_value($nd_display_settings, $build_mode, 'fields', $field, 'weight', ND_DEFAULT_WEIGHT);
      $form[$field]['nd_weight']['#default_value'] = nd_default_value($nd_display_settings, $build_mode, 'fields', $field, 'weight', ND_DEFAULT_WEIGHT);
      $form[$field][$build_mode]['label']['format']['#default_value'] = isset($value['display_settings'][$build_mode]['label']['format']) ? $value['display_settings'][$build_mode]['label']['format'] : nd_default_value($nd_display_settings, $build_mode, 'fields', $field, 'labelformat', ND_DEFAULT_LABEL_FORMAT);
      $form[$field][$build_mode]['format']['#options'] = isset($value['formatters']) ? $value['formatters'] : array();
      $format = nd_default_value($nd_display_settings, $build_mode, 'fields', $field, 'format', '');
      if (empty($format) && isset($value['formatters'])) {
        $format = key($value['formatters']);
      }
      $form[$field][$build_mode]['format']['#default_value'] = $format;
      $form[$field][$build_mode]['format']['#access'] = count($form[$field][$build_mode]['format']['#options']) == 1 || count($form[$field][$build_mode]['format']['#options']) == 0 ? FALSE : TRUE;
      $form[$field][$build_mode]['region']['#default_value'] = nd_default_value($nd_display_settings, $build_mode, 'fields', $field, 'region', ND_DEFAULT_REGION);
    }
  }
}