When attempting to move core-provided form actions into the reserved button area that jQuery UI Dialog implements by setting drupalAutoButtons = TRUE
within data-dialog-options
, the expected behavior does not occur. Instead, only confirm forms (like delete block/section forms) move the buttons when in a dialog. This is because ConfirmFormBase
seems to be the only base class that implements $form['actions']['#type'] = 'actions';
. This theme wrapper type needs to be implemented in all AJAX forms that could be rendered in a modal/ui-dialog so that Drupal.behaviors.dialog::prepareDialogButtons
can find the form actions based on the expected selectors (.form-actions input[type=submit], .form-actions a.button, .form-actions a.action-link
).
hook_form_FORM_ID_alter()
for ConfigureBlockFormBase
(used in following examples) or any other Layout Builder provided form that extends FormBase
.hook_link_alter()
for the link that corresponds to the form from the previous step:
hook_contextual_links_alter()
.$links['layout_builder_block_update']['localized_options']['attributes']['data-dialog-type'] = 'dialog';
.$links['layout_builder_block_update']['localized_options']['attributes']['data-dialog-options'] = Json::encode(['modal' => TRUE,]);
.unset($links['layout_builder_block_update']['localized_options']['attributes']['data-dialog-renderer']);
.['data-dialog-options']
to move buttons/actions within ui-dialog: $variables['options']['attributes']['data-dialog-options'] = Json::encode(['drupalAutoButtons' => TRUE, 'buttons' => ['ok' => [],],]);
(random "ok" button that does nothing, but helps in debugging).Update Layout Builder provided forms that extend FormBase
to utilize the actions theme wrapper: $form['actions']['#type'] = 'actions';
.
None
None expected
None
TBD
Active
11.0 π₯
Last updated