2

I am using drupal 7.10 I have a content type in which i want to change the save button text to submit.I tried various posts in this forum to no avail.i need help on this.Thanks in advance.

4 Answers 4

7

This is the complete $form['actions']['submit'] array the Node module uses for the form.

  $form['actions']['submit'] = array(
      '#type' => 'submit',
      '#access' => variable_get('node_preview_' . $type, DRUPAL_OPTIONAL) != DRUPAL_REQUIRED || (!form_get_errors() && isset($form_state['node_preview'])),
      '#value' => t('SaveTest'),
      '#weight' => 5,
      '#submit' => array('node_form_submit'),
   );

You need to hook into the node form.

/**
 * Implements hook_form_alter().
*/
function MYMODULE_form_alter(&$form, $form_state, $form_id) {
  if (isset($form['#node']) && $form_id == YOUR_NODE_TYPE . '_node_form') {
    $form['actions']['submit']['#value'] = t('YOUR_NEW_VALUE'),
  }
}
0
6

This should be pretty easy using a hook_form_alter, replace CONTENTTYPE with the machine readable name of your content type and MYMODULE, remember to always use underscores ("_") too.

function MYMODULE_form_alter(&$form, &$form_state, $form_id) {
   if ($form_id == 'CONTENTTYPE_node_form') {
         $form['buttons']['submit']['#value'] = "submit";
   }
}
0
2

Due the mistake I did, I'm going to change my answer from:

function YOUR_MODULE_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'CONTENT_TYPE_node_form') {
     $form['actions']['submit'] = array(
              '#value' => t('your_value'),
     );
  }
}

or via jQuery...

$('#form_id').val('your value');

to:

function YOUR_MODULE_form_alter(&$form, $form_state, $form_id) {
  if (isset($form['#node']) && $form_id == CONTENT_TYPE . '_node_form') {
    $form['actions']['submit']['#value'] = t('your_value'),
  }
}

or via jQuery

$('#form_id #input_id').val('your value');
0
2

Try out Node buttons edit module.

This is a simple little module that allows one to change the text on the 'Save', 'Preview' and 'Delete' buttons on a node form.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.