You are here

public static function AddressDefaultWidget::makeFieldsOptional in Address 8

Form API callback: Makes all address field properties optional.

File

src/Plugin/Field/FieldWidget/AddressDefaultWidget.php, line 149

Class

AddressDefaultWidget
Plugin implementation of the 'address_default' widget.

Namespace

Drupal\address\Plugin\Field\FieldWidget

Code

public static function makeFieldsOptional(array $element, FormStateInterface $form_state) {
  foreach (Element::getVisibleChildren($element) as $key) {
    if (!empty($element[$key]['#required'])) {
      $element[$key]['#required'] = FALSE;
    }
  }
  return $element;
}