views:

546

answers:

2

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
Doesnt work. I use drupal 6? There is not title value in the form object,
RD
you're right, drupal_set_title should be enough though (I edit the post)
gpilotino
+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
  • modify the 'product_node_form' as mentioned by gpilotino (minus the $form['title']['#title'] = 'foobar' - you only need the drupal_set_title('foobar')). this is a little harder, as you have to write your own module.
ax