function auto_nodetitle_inline_entity_form_entity_form_alter in Automatic Nodetitles 7
Implements hook_inline_entity_form_entity_form_alter().
File
- ./
auto_nodetitle.module, line 46 - Allows hiding of the node title field and automatic title creation.
Code
function auto_nodetitle_inline_entity_form_entity_form_alter(&$entity_form, &$form_state) {
if ($entity_form['#entity_type'] == 'node') {
$setting = auto_nodetitle_get_setting($entity_form['#entity']->type);
if ($setting == AUTO_NODETITLE_ENABLED) {
// We will autogenerate the title later, just hide the title field in the
// meanwhile.
$entity_form['title']['#value'] = 'ant';
$entity_form['title']['#type'] = 'value';
$entity_form['title']['#required'] = FALSE;
// Fix for title replaced field if title module is active.
if (module_exists('title') && isset($entity_form['title_field'])) {
$entity_form['title_field'][$entity_form['title_field']['#language']][0]['value']['#type'] = 'value';
$entity_form['title_field'][$entity_form['title_field']['#language']][0]['value']['#value'] = 'ant';
$entity_form['title_field'][$entity_form['title_field']['#language']][0]['value']['#required'] = FALSE;
}
}
elseif ($setting == AUTO_NODETITLE_OPTIONAL) {
$entity_form['title']['#required'] = FALSE;
if (module_exists('title') && isset($entity_form['title_field'])) {
$entity_form['title_field'][$entity_form['title_field']['#language']][0]['value']['#required'] = FALSE;
}
}
}
}