You are here

function node_class_form_alter in Node Class 7

Same name and namespace in other branches
  1. 6.2 node_class.module \node_class_form_alter()
  2. 6 node_class.module \node_class_form_alter()

File

./node_class.module, line 40

Code

function node_class_form_alter(&$form, &$form_state, $form_id) {

  // Check form type && if user_access is ok
  if (isset($form['#node']) && $form_id == $form['#node']->type . '_node_form' && user_access('administer nodes')) {
    $form['node_class'] = array(
      '#type' => 'fieldset',
      '#title' => t('Node Class settings'),
      '#collapsible' => TRUE,
      '#weight' => -1,
      '#tree' => TRUE,
    );

    // Get css attribute information
    $attributes = node_class_attributes($form['#node']);

    // Check CSS exists in DB to prepare SQL update
    if ($attributes) {
      $form['node_class']['existing_css'] = array(
        '#type' => 'hidden',
        '#value' => '1',
      );
    }
    $form['node_class']['css_class'] = array(
      '#type' => 'textfield',
      '#title' => t('CSS class(es)'),
      '#default_value' => $attributes,
      '#description' => t('Separate classes with a space.'),
    );

    // Add submit handler for node_class module
    $form['#submit'][] = 'node_class_form_submit';
  }
}