Drupal Tip #4 – Normal buttons with Drupal Form API

Drupal 6’s form API does not support input elements of type “button”. If you define one with ‘#type’=>’button’, it will be converted to a ‘#type’=>’submit’ automatically. So, how do you do it other than placing the button in a template file or function? You can use the ‘markup’ type, which is the default if no ‘#type’ key is defined. Example:

$form['submit'] = array(
'#value' => '<input type="button" onclick="return submitForm();" />',

Drupal 6 Form API Reference

Leave a Reply

Your email address will not be published. Required fields are marked *