You are here

function auto_nodetitle_form_node_form_alter in Automatic Nodetitles 8

Implements hook_form_FORM_ID_alter() for the node form.

File

./auto_nodetitle.module, line 32
Allows hiding of the node title field and automatic title creation.

Code

function auto_nodetitle_form_node_form_alter(&$form, &$form_state, $form_id) {
  $type = $form_state['controller']
    ->getEntity()
    ->getType();
  if (auto_nodetitle_get_setting($type) == AUTO_NODETITLE_ENABLED) {
    $widget =& $form['title']['widget'][0];

    // We will autogenerate the title later, just hide the title field in the
    // meanwhile.
    $widget['value']['#value'] = 'ant';
    $widget['value']['#type'] = 'hidden';
    $widget['value']['#required'] = FALSE;
  }
  elseif (auto_nodetitle_get_setting($type) == AUTO_NODETITLE_OPTIONAL) {
    $form['title']['#required'] = FALSE;
  }
}