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

alienbrain - April 18, 2007 - 19:59
Assigned to:Anonymous» alienbrain
Status:active» patch (code needs review)

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>';

AttachmentSize
node_submit_buttons.patch1.66 KB

#2

moshe weitzman - June 20, 2007 - 20:30
Title:Allow adding submit buttons to node-type forms» Allow adding submit buttons to node add/edit form
Status:patch (code needs review)» patch (reviewed & tested by the community)

I wish I had looked here before redoing this patch. Anyway, here is a refreshed version. Works as advertised.

AttachmentSize
mw_50.patch1.76 KB

#3

Gábor Hojtsy - June 23, 2007 - 13:07
Status:patch (reviewed & tested by the community)» fixed

Simple, straightforward, and with previous practice, so committed.

#4

Anonymous - July 7, 2007 - 13:15
Status:fixed» closed

#5

samo - September 4, 2007 - 23:28

Was this mod only applied to 6.x?

#6

Gábor Hojtsy - September 5, 2007 - 08:55

It would break backward compatibility on the form, so no way to apply it to 5.x IMHO.

 
 

Drupal is a registered trademark of Dries Buytaert.