Skip to content
Snippets Groups Projects
Commit 427aba8f authored by Roderik Muit's avatar Roderik Muit Committed by Lio Novelli
Browse files

Issue #3478276 by roderik, useernamee: Can not add fields to custom elements display

parent 282a5f77
No related branches found
No related tags found
1 merge request!98Fix AJAX error in UI form "add field" button on D10.3+
Pipeline #300834 passed with warnings
...@@ -4,6 +4,7 @@ namespace Drupal\custom_elements_ui\Form; ...@@ -4,6 +4,7 @@ namespace Drupal\custom_elements_ui\Form;
use Drupal\Component\Plugin\Factory\DefaultFactory; use Drupal\Component\Plugin\Factory\DefaultFactory;
use Drupal\Component\Plugin\PluginManagerBase; use Drupal\Component\Plugin\PluginManagerBase;
use Drupal\Core\Ajax\AjaxResponse;
use Drupal\Core\Ajax\ReplaceCommand; use Drupal\Core\Ajax\ReplaceCommand;
use Drupal\Core\Entity\EntityDisplayRepositoryInterface; use Drupal\Core\Entity\EntityDisplayRepositoryInterface;
use Drupal\Core\Entity\EntityFieldManagerInterface; use Drupal\Core\Entity\EntityFieldManagerInterface;
...@@ -805,12 +806,17 @@ class EntityCustomElementsDisplayEditForm extends EntityDisplayFormBase { ...@@ -805,12 +806,17 @@ class EntityCustomElementsDisplayEditForm extends EntityDisplayFormBase {
* {@inheritdoc} * {@inheritdoc}
*/ */
public function multistepAjax($form, FormStateInterface $form_state) { public function multistepAjax($form, FormStateInterface $form_state) {
$response = parent::multistepAjax($form, $form_state);
$trigger = $form_state->getTriggeringElement(); $trigger = $form_state->getTriggeringElement();
if ($trigger['#name'] == 'add_select') { if ($trigger['#name'] == 'add_select') {
// Replace the whole table. (Don't call parent, which can only handle
// its own known '#op's.)
$response = new AjaxResponse();
$response->addCommand(new ReplaceCommand('#field-display-overview-wrapper', $form['fields']));
$response->addCommand(new ReplaceCommand('.js-form-item-add-select', $form['add_select'])); $response->addCommand(new ReplaceCommand('.js-form-item-add-select', $form['add_select']));
} }
else {
$response = parent::multistepAjax($form, $form_state);
}
return $response; return $response;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment