You are here

function datex_schema_edit_form in Datex 7.2

Same name and namespace in other branches
  1. 7.3 datex.admin.inc \datex_schema_edit_form()

Menu callback, Admin form for editing datex schema.

1 string reference to 'datex_schema_edit_form'
datex_menu in ./datex.module
Implements hook_menu().

File

./datex.admin.inc, line 288

Code

function datex_schema_edit_form($form, $form_state, $name) {
  $list = _datex_schema_list();
  if (!in_array($name, $list)) {
    $form['notfound'] = array(
      '#markup' => t('Not found'),
    );
    return $form;
  }
  $schema = variable_get('datex_schema');
  $default = $schema[$name];
  $form['schemaname'] = array(
    '#type' => 'markup',
    '#markup' => '<h2> Name: ' . check_plain($name) . '</h2>',
  );
  $form['name'] = array(
    '#type' => 'value',
    '#value' => $name,
  );
  $options = _datex_api_available_calendars();
  foreach (language_list() as $code => $lang) {
    $calendar = isset($default[$code]) ? strval($default[$code]) : '0';
    $enabled = $calendar !== '0';
    $t = array(
      '@name' => $lang->name,
      '@native' => $lang->native,
    );
    $form['datex_' . $code] = array(
      '#type' => 'checkbox',
      '#title' => t('Enable datex in @name (@native)', $t),
      '#default_value' => $enabled ? '1' : '0',
    );
    $form[$code . '_calendar'] = array(
      '#type' => 'select',
      '#options' => drupal_map_assoc($options),
      '#title' => t('Calendar'),
      '#states' => array(
        'invisible' => array(
          ':input[name="datex_' . $code . '"]' => array(
            'checked' => FALSE,
          ),
        ),
      ),
      '#default_value' => $enabled ? $default[$code] : '',
    );
  }
  $form['actions']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save'),
    '#submit' => array(
      'datex_schema_edit_form_submit',
    ),
  );
  return $form;
}