3

In my custom module, I have added a button to the node edit form, using the following code.

  $form['actions']['my_submit'] = array(
    '#type' => 'submit',
    '#value' => t('My custom action'),
    '#weight' => -1000,
    '#submit' => array('node_form_submit', 'my_custom_node_form_submit')
  );

It is currently displayed either to the left or to the right of the standard "Save" button, depending on the weight value. Is there a way to display it on top of the form, before the first field?

1 Answer 1

3

If you use $form['actions']['my_submit'] like this, then you will get the button inside $form['actions']. $form['actions'] weight would be considered with the weight of other fields. Try the following code.

 $form['my_submit'] = array(
  '#type' => 'submit',
  '#value' => t('My custom action'),
  '#weight' => -1000,
  '#submit' => array('node_form_submit', 'my_custom_node_form_submit')
 );

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.