Allow adding submit buttons to node add/edit form
alienbrain - April 2, 2007 - 02:26
| Project: | Drupal |
| Version: | 6.x-dev |
| Component: | node.module |
| Category: | feature request |
| Priority: | normal |
| Assigned: | alienbrain |
| Status: | closed |
Description
If you want to add your own submit button besides "Preview" and "Submit" in node-types form, you normally think you will form_alter and add your button with let's say a weight of 1000 so it sinks. But no, node.module uses theme_node_form() to custom theme this form, so _whatever_ you do, it will render your buttons somewhere that you can't control using weights.

#1
This is a a simple solution to for this simple problem. Very similar to this snipper which is already in node_filter_form():
$form['filters']['buttons']['submit'] = array('#type' => 'submit', '#value' => (count($session) ? t('Refine') : t('Filter')));if (count($session)) {
$form['filters']['buttons']['undo'] = array('#type' => 'submit', '#value' => t('Undo'));
$form['filters']['buttons']['reset'] = array('#type' => 'submit', '#value' => t('Reset'));
}
...
..
$output .= '<div class="container-inline" id="node-admin-buttons">'. drupal_render($form['buttons']) .'</div>';
#2
I wish I had looked here before redoing this patch. Anyway, here is a refreshed version. Works as advertised.
#3
Simple, straightforward, and with previous practice, so committed.
#4
#5
Was this mod only applied to 6.x?
#6
It would break backward compatibility on the form, so no way to apply it to 5.x IMHO.