Verified Commit b825f8e2 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #2651418 by vasike, DieterHolvoet, smustgrave, Xano, rpayanm, quietone,...

Issue #2651418 by vasike, DieterHolvoet, smustgrave, Xano, rpayanm, quietone, alexpott, larowlan, catch, lauriii: Non-array values for #ajax

(cherry picked from commit fe3aa496)
parent e2acd9e0
Loading
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -183,6 +183,9 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta
        '#size' => 6,
        '#multiple' => TRUE,
        '#element_validate' => [[static::class, 'elementValidateFilter']],
        // Use a form process callback to build #ajax property properly and also
        // to avoid code duplication.
        // @see \Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem::fieldSettingsAjaxProcess()
        '#ajax' => TRUE,
        '#limit_validation_errors' => [],
      ];
@@ -232,6 +235,9 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta
        '#type' => 'select',
        '#title' => $this->t('Sort by'),
        '#options' => $fields,
        // Use a form process callback to build #ajax property properly and also
        // to avoid code duplication.
        // @see \Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem::fieldSettingsAjaxProcess()
        '#ajax' => TRUE,
        '#empty_value' => '_none',
        '#sort_options' => TRUE,
+5 −1
Original line number Diff line number Diff line
@@ -2,11 +2,11 @@

namespace Drupal\Core\Field\Plugin\Field\FieldType;

use Drupal\Component\Plugin\Exception\PluginNotFoundException;
use Drupal\Component\Render\FormattableMarkup;
use Drupal\Component\Utility\Html;
use Drupal\Core\Entity\ContentEntityStorageInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Component\Plugin\Exception\PluginNotFoundException;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Entity\FieldableEntityInterface;
use Drupal\Core\Entity\TypedData\EntityDataDefinition;
@@ -477,6 +477,9 @@ public function fieldSettingsForm(array $form, FormStateInterface $form_state) {
      '#options' => $handlers_options,
      '#default_value' => $field->getSetting('handler'),
      '#required' => TRUE,
      // Use a form process callback to build #ajax property properly and also
      // to avoid code duplication.
      // @see \Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem::fieldSettingsAjaxProcess()
      '#ajax' => TRUE,
      '#limit_validation_errors' => [],
    ];
@@ -703,6 +706,7 @@ public static function fieldSettingsAjaxProcess($form, FormStateInterface $form_
   * @see static::fieldSettingsAjaxProcess()
   */
  public static function fieldSettingsAjaxProcessElement(&$element, $main_form) {
    // Elements are marked as TRUE ('#ajax' => TRUE,), so not empty.
    if (!empty($element['#ajax'])) {
      $element['#ajax'] = [
        'trigger_as' => ['name' => 'handler_settings_submit'],
+3 −0
Original line number Diff line number Diff line
@@ -117,6 +117,9 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta
        '_none' => $this->t('- None -'),
        'role' => $this->t('User role'),
      ],
      // Use a form process callback to build #ajax property properly and also
      // to avoid code duplication.
      // @see \Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem::fieldSettingsAjaxProcess()
      '#ajax' => TRUE,
      '#limit_validation_errors' => [],
      '#default_value' => $configuration['filter']['type'],