You are here

function spaces_ui_form_alter in Spaces 5

Same name and namespace in other branches
  1. 5.2 spaces_ui.module \spaces_ui_form_alter()

Implementation of hook_form_alter()

File

./spaces_ui.module, line 61

Code

function spaces_ui_form_alter($form_id, &$form) {
  switch ($form_id) {
    case 'context_ui_form':
      if ($form['value']['#default_value']) {
        $feature = db_fetch_object(db_query('SELECT * FROM {spaces_features_ui} WHERE feature = "%s"', $form['value']['#default_value']));
      }
      if (arg(3) == 'feature' || is_object($feature)) {

        // Add Feature information to context form
        $form['feature'] = array(
          '#type' => 'fieldset',
          '#title' => 'Feature Settings',
          '#weight' => -5,
          '#tree' => true,
        );
        $form['feature']['label'] = array(
          '#type' => 'textfield',
          '#title' => t('Label'),
          '#description' => t('Name of the feature.'),
          '#required' => true,
          '#default_value' => $feature->label ? $feature->label : '',
        );
        $form['feature']['description'] = array(
          '#type' => 'textfield',
          '#title' => t('Description'),
          '#description' => t('A brief description of the feature.'),
          '#required' => true,
          '#default_value' => $feature->description ? $feature->description : '',
        );

        // Force key and space to be 'feature', 'spaces' so that the spaces module knows what to do.
        $form['attribute']['#disabled'] = true;
        $form['attribute']['#default_value'] = 'feature';
        $form['namespace']['#disabled'] = true;
        $form['namespace']['#default_value'] = 'spaces';
        $form['#submit']['spaces_context_form_feature_submit'] = array();
      }
      break;
  }
}