- Issue created by @skrug
- 🇩🇪Germany skrug Bamberg
Changed version from 8.x-3.0-rc14 to 4.0.2 because this also applies for this version but it all started with version 8.x-3.0-rc14.
More precisely with commit https://git.drupalcode.org/project/gin/-/commit/c2d182f5e0d50c8c953eb192...In other themes ajax button are working as expected.
Other example which does not work:
function emp_save_edit_form_alter(array &$form, FormStateInterface $form_state, $form_id) { // Check if the form is a node edit form. if (str_starts_with($form['#form_id'], 'node_') && str_ends_with($form['#form_id'], 'edit_form')) { // Add a custom save button. $form['actions']['custom_save'] = [ '#type' => 'submit', '#value' => t('Custom Save'), '#ajax' => [ 'callback' => '_emp_save_edit_custom_save_ajax_callback', 'wrapper' => 'node-edit-form-wrapper', 'effect' => 'fade', ], '#submit' => ['_emp_save_edit_custom_save_submit'], '#weight' => 10, '#gin_action_item' => TRUE, ]; } } /** * AJAX callback for the custom save button. */ function _emp_save_edit_custom_save_ajax_callback(array &$form, FormStateInterface $form_state) { // Return the form to be re-rendered. return $form; } /** * Custom submit handler for the custom save button. */ function _emp_save_edit_custom_save_submit(array &$form, FormStateInterface $form_state) { // Custom logic for saving the node. // For example, you can save the node with custom logic or set a message. $node = $form_state->getFormObject()->getEntity(); \Drupal::messenger()->addMessage(t('Node @title has been saved with custom logic.', ['@title' => $node->getTitle()])); $node->save(); }
- First commit to issue fork.
- Merge request !576Issue #3499408: custom ajax button not working anymore → (Merged) created by volkerk
- 🇨🇭Switzerland saschaeggi Zurich
This probably needs a rebase since we've merged 🐛 Sticky actions fail on Ajax Active
Thanks 🙇
- 🇸🇮Slovenia miha.wagner
Can confirm the patch provided via the MR fixes the ajax button issue. RTBTC +1.
- 🇩🇪Germany skrug Bamberg
I can also confirm that fix provided in the branch fixes the issue. RTBTC + 1
Thanks everyone. -
saschaeggi →
committed 9a01ff17 on 4.0.x authored by
volkerk →
Issue #3499408: custom ajax button not working anymore
-
saschaeggi →
committed 9a01ff17 on 4.0.x authored by
volkerk →
- 🇨🇭Switzerland saschaeggi Zurich
Included in the 4.0.4 release: https://www.drupal.org/project/gin/releases/4.0.4 →
Automatically closed - issue fixed for 2 weeks with no activity.