From e6c55aaa1eebfa6333d4257f62bebdc18c2a656e Mon Sep 17 00:00:00 2001 From: Jaime Herencia Date: Thu, 9 Aug 2012 04:03:14 +0200 Subject: [PATCH] Issue #1719948 by jherencia: Integration with inline entity form --- auto_nodetitle.module | 23 ++++++++++++----------- 1 files changed, 12 insertions(+), 11 deletions(-) diff --git a/auto_nodetitle.module b/auto_nodetitle.module index 30e6e4f..1b72107 100644 --- a/auto_nodetitle.module +++ b/auto_nodetitle.module @@ -23,18 +23,19 @@ function auto_nodetitle_permission() { } /** - * Implements hook_form_FORM_ID_alter() for the node form. + * Implements hook_field_attach_form(). */ -function auto_nodetitle_form_node_form_alter(&$form, &$form_state, $form_id) { - if (auto_nodetitle_get_setting($form['#node']->type) == AUTO_NODETITLE_ENABLED) { - // We will autogenerate the title later, just hide the title field in the - // meanwhile. - $form['title']['#value'] = 'ant'; - $form['title']['#type'] = 'value'; - $form['title']['#required'] = FALSE; - } - elseif (auto_nodetitle_get_setting($form['#node']->type) == AUTO_NODETITLE_OPTIONAL) { - $form['title']['#required'] = FALSE; +function auto_nodetitle_field_attach_form($entity_type, $entity, &$form, &$form_state, $langcode) { + if ($entity_type == 'node') { + $setting = auto_nodetitle_get_setting($entity->type); + if ($setting == AUTO_NODETITLE_ENABLED) { + $form['title']['#value'] = 'ant'; + $form['title']['#type'] = 'value'; + $form['title']['#required'] = FALSE; + } + elseif ($setting == AUTO_NODETITLE_OPTIONAL) { + $form['title']['#required'] = FALSE; + } } } -- 1.7.5.4