1 field_group.field_ui.inc field_group_add_row($name, array $parent_options, $params)

Helper function to add a row in the overview forms.

Parameters

string $name: Machine name.

array $parent_options: An array of field group parents.

object $params: Group parameters.

File

core/modules/field_group/field_group.field_ui.inc, line 434
Field_group.field_ui.inc is a file that contains most functions needed on the Fields UI Manage forms (display and fields).

Code

function field_group_add_row($name, array $parent_options, $params) {
  return array(
    '#attributes' => array(
      'class' => array('draggable', 'field-group', 'add-new'),
    ),
    '#row_type' => 'add_new_group',
    '#js_settings' => array('rowHandler' => 'group'),
    '#region_callback' => $params->region_callback,
    'label' => array(
      '#title_display' => 'invisible',
      '#title' => t('Label for new group'),
      '#type' => 'textfield',
      '#size' => 15,
      '#description' => t('Label'),
      '#prefix' => '<div class="label-input"><div class="add-new-placeholder">' . t('Add new group') . '</div>',
      '#suffix' => '</div>',
    ),
    'weight' => array(
      '#type' => 'textfield',
      '#default_value' => (int) field_info_max_weight($params->entity_type, $params->bundle, $params->mode) + 3,
      '#size' => 3,
      '#title_display' => 'invisible',
      '#title' => t('Weight for new group'),
      '#attributes' => array('class' => array('field-weight')),
      '#prefix' => '<div class="add-new-placeholder">&nbsp;</div>',
    ),
    'parent_wrapper' => array(
      'parent' => array(
        '#title_display' => 'invisible',
        '#title' => t('Parent for new group'),
        '#type' => 'select',
        '#options' => $parent_options,
        '#empty_value' => '',
        '#attributes' => array('class' => array('field-parent')),
        '#prefix' => '<div class="add-new-placeholder">&nbsp;</div>',
        '#parents' => array('fields', $name, 'parent'),
      ),
      'hidden_name' => array(
        '#type' => 'hidden',
        '#default_value' => $name,
        '#attributes' => array('class' => array('field-name')),
      ),
    ),
    'group_name' => array(
      '#type' => 'machine_name',
      '#title' => t('New field name'),
      '#title_display' => 'invisible',
      // This field should stay LTR even for RTL languages.
      '#field_prefix' => '<span dir="ltr">group_',
      '#field_suffix' => '</span>&lrm;',
      '#size' => 15,
      '#description' => t('A unique machine-readable name containing letters, numbers, and underscores.'),
      // 32 characters minus the 'field_' prefix.
      '#maxlength' => 26,
      '#prefix' => '<div class="add-new-placeholder">&nbsp;</div>',
      '#machine_name' => array(
        'source' => array('fields', $name, 'label'),
        'exists' => '_field_group_group_name_exists',
        'standalone' => TRUE,
        'label' => '',
      ),
      '#required' => FALSE,
      '#cell_attributes' => array('colspan' => $params->display_overview ? 1 : 2),
    ),
  );
}