You are here

function msnf_add_row in Multistep Nodeform 7

Helper function to add a row in the overview forms.

1 call to msnf_add_row()
msnf_field_ui_overview_form_alter in includes/msnf.field_ui.inc
Function to alter the fields overview screen.

File

includes/msnf.field_ui.inc, line 301
msnf.field_ui.inc is a file that contains most functions needed on the Fields UI Manage forms (display and fields).

Code

function msnf_add_row($name, $parent_options, $params) {
  if (!isset($params->mode)) {
    $params->mode = 'form';
  }
  return array(
    '#attributes' => array(
      'class' => array(
        'draggable',
        'msnf-step',
        'add-new',
      ),
    ),
    '#row_type' => 'add_new_step',
    '#js_settings' => array(
      'rowHandler' => 'group',
    ),
    '#region_callback' => $params->region_callback,
    'label' => array(
      '#type' => 'textfield',
      '#size' => 15,
      '#description' => t('Label'),
      '#prefix' => '<div class="label-input"><div class="add-new-placeholder">' . t('Add new step') . '</div>',
      '#suffix' => '</div>',
    ),
    'weight' => array(
      '#type' => 'textfield',
      '#default_value' => field_info_max_weight($params->entity_type, $params->bundle, $params->mode) + 3,
      '#size' => 3,
      '#title_display' => 'invisible',
      '#title' => t('Weight for new step'),
      '#attributes' => array(
        'class' => array(
          'field-weight',
        ),
      ),
      '#prefix' => '<div class="add-new-placeholder">&nbsp;</div>',
    ),
    'parent_wrapper' => array(
      'parent' => array(
        '#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',
          ),
        ),
      ),
    ),
    'step_name' => array(
      '#type' => 'machine_name',
      '#title' => t('New step name'),
      '#title_display' => 'invisible',
      // This field should stay LTR even for RTL languages.
      '#field_prefix' => '<span dir="ltr">step_',
      '#field_suffix' => '</span>&lrm;',
      '#attributes' => array(
        'dir' => 'ltr',
      ),
      '#size' => 15,
      // Set max length to prevent users from entering names that are to long.
      '#max_length' => 27,
      '#description' => t('Step name (a-z, 0-9, _)'),
      '#prefix' => '<div class="add-new-placeholder">&nbsp;</div>',
      '#machine_name' => array(
        'source' => array(
          'fields',
          $name,
          'label',
        ),
        'exists' => '_msnf_step_name_exists',
        'standalone' => TRUE,
        'label' => '',
      ),
      '#required' => FALSE,
      '#cell_attributes' => array(
        'colspan' => 2,
      ),
    ),
  );
}