You are here

function uc_extra_fields_pane_form in Extra Fields Checkout Pane 6

1 string reference to 'uc_extra_fields_pane_form'
uc_extra_fields_pane_menu in ./uc_extra_fields_pane.module

File

./uc_extra_fields_pane.module, line 280

Code

function uc_extra_fields_pane_form($form_state) {
  $fields = uc_extra_fields_pane_load_fields_from_db();
  $page_content .= "";
  $form['ucxf'] = array(
    '#tree' => TRUE,
    '#summary callback' => '_uc_extra_fields_pane_summarize',
    '#summary arguments' => array(
      $fields,
    ),
  );
  if (count($fields)) {
    $headers = array();
    $headers[] = array(
      'data' => t('Label'),
    );
    $headers[] = array(
      'data' => t('Field name'),
    );
    $headers[] = array(
      'data' => t('Required'),
    );
    $headers[] = array(
      'data' => t('Description'),
    );
    $headers[] = array(
      'data' => t('Actions'),
    );
    $rows = array();
    foreach ($fields as $field) {
      $content = array();
      $content[] = array(
        'data' => $field['title'],
      );
      $content[] = array(
        'data' => $field['field'],
      );
      $content[] = array(
        'data' => $field['required'] == 1 ? t('Yes') : t('No'),
      );
      $content[] = array(
        'data' => $field['description'],
      );
      $content[] = array(
        'data' => l(t('delete'), 'admin/store/settings/extrafields/' . $field['id'] . '/delete') . ' | ' . l(t('edit'), 'admin/store/settings/extrafields/' . $field['id'] . '/edit'),
      );
      $rows[] = $content;
    }
    $page_content = theme_table($headers, $rows);
    $form['ucxf']['current-fields'] = array(
      '#type' => 'fieldset',
      '#title' => t('Manage fields'),
      '#collapsible' => TRUE,
      '#collapsed' => FALSE,
    );
    $form['ucxf']['current-fields']['table'] = array(
      '#value' => $page_content,
    );
  }
  $form['ucxf']['add_one_more_field'] = array(
    '#type' => 'fieldset',
    '#title' => t('Create new field'),
    '#collapsible' => FALSE,
    '#collapsed' => FALSE,
  );
  $form['ucxf']['add_one_more_field']['label'] = array(
    '#title' => t('Label'),
    '#type' => 'textfield',
    '#size' => 15,
    '#description' => t('Label shown to customers in checkout pages.'),
  );
  $form['ucxf']['add_one_more_field']['field_name'] = array(
    '#title' => t('Field name'),
    '#type' => 'textfield',
    '#size' => 15,
    '#description' => t('Database field name. It must contain only lower chars a-z, digits 0-9 and _. Max allowed lenght is 23 characters.'),
  );
  $form['ucxf']['add_one_more_field']['description'] = array(
    '#title' => t('Description'),
    '#type' => 'textarea',
    '#rows' => 3,
    '#description' => t('Insert a description to tell customers how to fill this field.'),
  );
  $form['ucxf']['add_one_more_field']['required'] = array(
    '#title' => t('Field required'),
    '#type' => 'checkbox',
    '#description' => t('Check this item is field is mandatory.'),
  );
  $form['ucxf']['add_one_more_field']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save'),
  );
  return $form;
}