You are here

function nd_build_mode_form in Node displays 6

Build mode form.

1 string reference to 'nd_build_mode_form'
nd_build_modes in includes/nd.buildmodes.inc
Build modes overview.

File

includes/nd.buildmodes.inc, line 178
Manage build modes.

Code

function nd_build_mode_form($form_state, $build_mode = '') {
  $form = array();
  if (!empty($build_mode)) {
    $build_modes = variable_get('nd_build_modes', array());
    $title = $build_modes[$build_mode];
  }
  else {
    $title = '';
  }
  $form['identity'] = array(
    '#type' => 'fieldset',
    '#title' => empty($build_mode) ? t('Add new build mode') : t('Update build mode'),
    '#collapsible' => empty($build_mode) ? TRUE : FALSE,
    '#collapsed' => empty($build_mode) ? TRUE : FALSE,
  );
  $form['identity']['key'] = array(
    '#type' => 'textfield',
    '#title' => 'Key name',
    '#description' => t('The machine-readable name of this build mode.'),
    '#required' => TRUE,
  );
  if (!empty($build_mode)) {
    $form['identity']['key']['#disabled'] = TRUE;
    $form['identity']['key']['#value'] = $build_mode;
    $form['identity']['key']['#description'] = t('The machine-readable name of this build mode. Note: you can not edit this field.');
  }
  $form['identity']['name'] = array(
    '#type' => 'textfield',
    '#title' => 'Display name',
    '#description' => t('The name of this build mode which will be used for every content type on the display fields page.'),
    '#required' => TRUE,
    '#default_value' => $title,
  );
  $form['identity']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save display'),
    '#submit' => array(
      'nd_build_mode_form_submit',
    ),
  );
  $form['#form_type'] = empty($build_mode) ? 'insert' : 'update';
  return $form;
}