I found a discussion with some methods for d6 here http://drupal.org/node/344802 on how to change the node "Save" button text to sg else.
Any tips for d7? I would prefer to use form api.
I found a discussion with some methods for d6 here http://drupal.org/node/344802 on how to change the node "Save" button text to sg else.
Any tips for d7? I would prefer to use form api.
you could use string overrides module or use hook:
function yourmodule_form_alter(&$form, &$form_state, $form_id) {
if ($form_id == 'name_of_form') {
$form['actions']['submit']['#value'] = 'Your button text';
}
}
Here is an example: I have created a module called change_form_values
and the form ID of my content type is content_type_test_node_form
:
this work for me in Drupal 7:
function change_form_values_form_alter(&$form, &$form_state, $form_id) {
//dsm($form_id); // to see form ID
if ($form_id == "content_type_test_node_form") {
$form['actions']['submit']['#value'] = 'New button text';
}
}
this work for me in Drupal 6:
function change_form_values_form_alter(&$form, &$form_state, $form_id) {
//dsm($form['form_id']['#id']);
if ($form_id == "content_type_test_node_form") {
$form['buttons']['submit']['#value'] = 'New button text';
}
}
I hope information be useful.
I found the excellent Node buttons edit module for this and it works really our of the box using admin. Here is an excerpt about it from the module's project page:
This is a simple little module that allows one to change the text on the 'Save', 'Preview' and 'Delete' buttons on a node form.
For Drupal7 it's simple just:
$form['buttons'] = array(
'#type' => 'submit',
'#value' => t('Your desire text here'),
);
Wihtout adicional functions...
#weight
, #validate
, #submit
...). You'ld better go only for the #value
, like written in the other answers above.