Let's say I have a node called "product". When I create such a node, it will always display: "Create product" as the title of the node. How do I change this title WHEN CREATING THE NODE?
A:
try with
yourmodule_form_product_node_form_alter(&$form, $form_state)
{
drupal_set_title($foobar);
}
gpilotino
2009-09-08 11:53:31
Doesnt work. I use drupal 6? There is not title value in the form object,
RD
2009-09-08 13:12:49
you're right, drupal_set_title should be enough though (I edit the post)
gpilotino
2009-09-08 18:49:45
+4
A:
you mean you have a content type "product"?
the "Create product" title when creating a node of type "product" is set in node_add($type)
:
// ...
drupal_set_title(t('Create @name', array('@name' => $types[$type]->name)));
$output = drupal_get_form($type .'_node_form', $node);
// ...
there are at least 2 options to change this:
- change the translatable string 'Create @name' (indicated by the
t()
it is passed through) via- settings.php - search for
locale_custom_strings_
, or - http://drupal.org/project/stringoverrides
- settings.php - search for
- modify the 'product_node_form' as mentioned by gpilotino (minus the
$form['title']['#title'] = 'foobar'
- you only need thedrupal_set_title('foobar')
). this is a little harder, as you have to write your own module.
ax
2009-09-08 14:38:45