You are here

function data_ui_create_form in Data 6

Same name and namespace in other branches
  1. 7 data_ui/data_ui.admin.inc \data_ui_create_form()

Form callback for create table form.

1 string reference to 'data_ui_create_form'
data_ui_menu in data_ui/data_ui.module
Implementation of hook_menu()

File

data_ui/data_ui.admin.inc, line 286
Admin UI functions.

Code

function data_ui_create_form(&$form_state) {
  $form = array();
  if (!$form_state['storage']['field_num']) {
    $form['name'] = array(
      '#type' => 'textfield',
      '#title' => t('Table name'),
      '#description' => t('Machine readable name of the table - e. g. "my_table". Must only contain lower case letters and _.'),
      '#required' => TRUE,
    );
    $form['title'] = array(
      '#type' => 'textfield',
      '#title' => t('Table title'),
      '#description' => t('Natural name of the table - e. g. "My Table".'),
      '#required' => TRUE,
    );
    $form['field_num'] = array(
      '#type' => 'textfield',
      '#title' => t('Number of fields'),
      '#description' => t('The number of fields this table should contain.'),
      '#default_value' => 1,
      '#required' => TRUE,
    );
    $form['submit'] = array(
      '#type' => 'submit',
      '#value' => t('Next'),
    );
  }
  else {
    $form['help']['#value'] = t('Define the fields of the new table.');
    $form['fields'] = array(
      '#tree' => TRUE,
    );
    for ($i = 0; $i < $form_state['storage']['field_num']; $i++) {
      $form['fields']['field_' . $i] = _data_ui_field_form(TRUE);
    }
    $form['submit'] = array(
      '#type' => 'submit',
      '#value' => t('Create'),
    );
  }
  return $form;
}