You are here

function defaultcontent_form_alter in Default Content 7

Same name and namespace in other branches
  1. 7.2 defaultcontent.module \defaultcontent_form_alter()

Implements hook_form_alter().

Add machine name to node form TODO: get the machine_name type to work

File

./defaultcontent.module, line 56
Module file for the Default content module which allow export and import of default content in a Drupal site.

Code

function defaultcontent_form_alter(&$form, &$form_state, $form_id) {
  if (user_access('edit node machine name') && strpos($form_id, 'node_form')) {
    $form['machine_name_fs'] = array(
      '#type' => 'fieldset',
      '#title' => 'Machine Name',
      '#group' => 'additional_settings',
    );
    $form['machine_name_fs']['machine_name'] = array(
      '#type' => 'machine_name',
      '#type' => 'textfield',
      '#title' => 'Machine Name',
      '#required' => FALSE,
      '#description' => 'Provide a unique name for this node',
      '#default_value' => isset($form_state['node']->machine_name) ? $form_state['node']->machine_name : '',
    );
  }
}