function BlockEntitySettingTrayForm::buildForm
Same name in other branches
- 8.9.x core/modules/settings_tray/src/Block/BlockEntitySettingTrayForm.php \Drupal\settings_tray\Block\BlockEntitySettingTrayForm::buildForm()
- 10 core/modules/settings_tray/src/Block/BlockEntitySettingTrayForm.php \Drupal\settings_tray\Block\BlockEntitySettingTrayForm::buildForm()
- 11.x core/modules/settings_tray/src/Block/BlockEntitySettingTrayForm.php \Drupal\settings_tray\Block\BlockEntitySettingTrayForm::buildForm()
Overrides EntityForm::buildForm
File
-
core/
modules/ settings_tray/ src/ Block/ BlockEntitySettingTrayForm.php, line 124
Class
- BlockEntitySettingTrayForm
- Provides form for block instance forms when used in the off-canvas dialog.
Namespace
Drupal\settings_tray\BlockCode
public function buildForm(array $form, FormStateInterface $form_state) {
$form = parent::buildForm($form, $form_state);
$form['actions']['submit']['#ajax'] = [
'callback' => '::ajaxSubmit',
];
$form['#attached']['library'][] = 'core/drupal.dialog.ajax';
// static::ajaxSubmit() requires data-drupal-selector to be the same between
// the various Ajax requests. A bug in \Drupal\Core\Form\FormBuilder
// prevents that from happening unless $form['#id'] is also the same.
// Normally, #id is set to a unique HTML ID via Html::getUniqueId(), but
// here we bypass that in order to work around the data-drupal-selector bug.
// This is okay so long as we assume that this form only ever occurs once on
// a page.
// @todo Remove this workaround once https://www.drupal.org/node/2897377 is
// fixed.
$form['#id'] = Html::getId($form_state->getBuildInfo()['form_id']);
return $form;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.