diff --git a/core/includes/theme.inc b/core/includes/theme.inc index 9d25f33..5c902da 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -1647,7 +1647,9 @@ function template_preprocess_field_multiple_value_form(&$variables) { ['data' => $remove_element, 'class' => ['delta-remove']], ]; $class = ['draggable']; - if (!empty($remove_element['check']['#checked'])) $class[] = 'removed'; + if (!empty($remove_element['check']['#checked'])) { + $class[] = 'removed'; + } $rows[] = [ 'data' => $cells, 'class' => $class, diff --git a/core/lib/Drupal/Core/Field/WidgetBase.php b/core/lib/Drupal/Core/Field/WidgetBase.php index 3f00bce..64a3ae4 100644 --- a/core/lib/Drupal/Core/Field/WidgetBase.php +++ b/core/lib/Drupal/Core/Field/WidgetBase.php @@ -202,24 +202,15 @@ protected function formMultipleElements(FieldItemListInterface $items, array &$f '#default_value' => $items[$delta]->_weight ?: $delta, '#weight' => 100, ]; - - foreach (Element::children($element) as $key) { - $element[$key]['#states'] = [ - 'disabled' => [ - ':input[name="' . $field_name . '[' . $delta . '][_remove][check]"]' => ['checked' => TRUE], - ], - ]; - } - $element['_remove']['check'] = [ '#title' => $this->t('Remove'), '#title_display' => 'invisible', '#type' => 'checkbox', - '#attributes' => ['class' => ['hidden']], '#weight' => 101, ]; $element['_remove']['button'] = [ '#type' => 'button', + '#attributes' => ['class' => ['hidden']], '#value' => t('Remove'), '#weight' => 102, ]; @@ -376,7 +367,9 @@ public function extractFormValues(FieldItemListInterface $items, array $form, Fo // Filter out removed items. foreach ($values as $delta => $value) { - if (!empty($value['_remove']['check'])) unset($values[$delta]); + if (!empty($value['_remove']['check'])) { + unset($values[$delta]); + } } // The original delta, before drag-and-drop reordering, is needed to diff --git a/core/misc/form.js b/core/misc/form.js index 308ad87..06f81d0 100644 --- a/core/misc/form.js +++ b/core/misc/form.js @@ -275,7 +275,7 @@ var $table = $(table); // For each of the remove buttons within the table. - $table.find('td.delta-remove input[type="submit"]').on('click', function (e) { + $table.find('td.delta-remove input[type="submit"]').removeClass('hidden').on('click', function (e) { // Either add or remove the removed class based on the state of the // hidden remove checkbox. diff --git a/core/themes/classy/css/components/form.css b/core/themes/classy/css/components/form.css index 78c4323..d6ba76a 100644 --- a/core/themes/classy/css/components/form.css +++ b/core/themes/classy/css/components/form.css @@ -6,7 +6,11 @@ form .field-multiple-table { margin: 0; } -form .field-multiple-table tr.removed { +form .field-multiple-table tr.removed, +form .field-multiple-table .delta-remove .hidden { + display: none; +} +.js form .field-multiple-table .delta-remove .form-checkbox { display: none; } form .field-multiple-table .field-multiple-drag {