You are here

public static function AddressItem::fieldOverridesValidate in Address 8

Form element validation handler: Removes empty field overrides.

Parameters

array $element: The field overrides form element.

\Drupal\Core\Form\FormStateInterface $form_state: The form state of the entire form.

File

src/Plugin/Field/FieldType/AddressItem.php, line 235

Class

AddressItem
Plugin implementation of the 'address' field type.

Namespace

Drupal\address\Plugin\Field\FieldType

Code

public static function fieldOverridesValidate(array $element, FormStateInterface $form_state) {
  $overrides = $form_state
    ->getValue($element['#parents']);
  $overrides = array_filter($overrides, function ($data) {
    return !empty($data['override']);
  });
  $form_state
    ->setValue($element['#parents'], $overrides);
}