- πΊπΈUnited States smustgrave
Thank you everyone for this.
Closing as outdated as there hasn't been a follow up for #22
If still a bug please reopen updating issue summary for D10
Thanks!
When two buttons are added to a form, one vanilla HTML button and one image button, $form_state['triggering_element'] is always the image button regardless of which button is clicked. If both buttons are HTML buttons then the triggering element is set properly. If both buttons are image buttons, the last button in the form will be the triggering element. This is true when using both ajax and normal submit.
In order to demonstrate, I have created a content type called "test" and used the following code for the buttons and their ajax callbacks.
<!--break-->/**
* Implements hook_form_FORM_ID_alter().
*/
function mymodule_form_test_node_form_alter(&$form, &$form_state, $form_id) {
$form['html_button'] = array(
'#type' => 'button',
'#value' => 'HTML button',
'#ajax' => array(
'callback' => 'mymodule_button_html_callback',
'wrapper' => 'mymodule_replace',
),
);
$form['image_button'] = array(
'#type' => 'image_button',
'#value' => 'Image button',
'#src' => drupal_get_path('module', 'mymodule') . '/image.jpg',
'#ajax' => array(
'callback' => 'mymodule_button_image_callback',
'wrapper' => 'mymodule_replace',
),
);
$form['#prefix'] = '<div id="mymodule_replace">';
$form['#suffix'] = '</div>';
}
/**
* Callback function for the HTML button's ajax event.
*/
function mymodule_button_html_callback(&$form, &$form_state) {
drupal_set_message('HTML button');
return $form;
}
/**
* Callback function for the image button's ajax event.
*/
function mymodule_button_image_callback(&$form, &$form_state) {
drupal_set_message('Image button');
return $form;
}
Closed: outdated
9.5
Last updated
Worse Than Failure. Approximates the unpleasant remark made by Drupal developers when they first encounter a particular (mis)feature.
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.
Thank you everyone for this.
Closing as outdated as there hasn't been a follow up for #22
If still a bug please reopen updating issue summary for D10
Thanks!