I am trying to have a button which is not a "submit" type of button, but rather a normal "button" type, using the forms api of drupal 7, but I can't seem to get it.
I've tried many things, like setting #type to 'button', setting #button_type to 'button' but no matter what I do, drupal always creates a button of type "submit".
You can use:
"#executes_submit_callback" => FALSE
To disable the "submit" step.
If you only want to disable the "validate" step, use:
"#limit_validation_errors" => array()
In Drupal 7 this can be accomplished by adding:
'#attributes' => array('onclick' => 'return (false);'),
to your button definition. For example:
$form['my_form'] = array(
'#type' => 'button',
'#attributes' => array('onclick' => 'return (false);'),
'#value' => t('My Button'),
'#prefix' => t('<div class="myButton">'),
'#suffix' => t('</div>')
);
This worked for my application.
Reference: https://www.drupal.org/node/283065 under Disabling and Overriding Buttons
You may want to check out this issue for some background and then consider this workaround. You might also be able to use #markup to insert it manually.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With