function FieldConfigEditForm::hasAnyRequired

Same name in other branches
  1. 11.x core/modules/field_ui/src/Form/FieldConfigEditForm.php \Drupal\field_ui\Form\FieldConfigEditForm::hasAnyRequired()

A function to check if element contains any required elements.

Parameters

array $element: An element to check.

Return value

bool

1 call to FieldConfigEditForm::hasAnyRequired()
FieldConfigEditForm::form in core/modules/field_ui/src/Form/FieldConfigEditForm.php
Gets the actual form array to be built.

File

core/modules/field_ui/src/Form/FieldConfigEditForm.php, line 313

Class

FieldConfigEditForm
Provides a form for the field settings form.

Namespace

Drupal\field_ui\Form

Code

private function hasAnyRequired(array $element) {
    $has_required = FALSE;
    foreach (Element::children($element) as $child) {
        if (isset($element[$child]['#required']) && $element[$child]['#required']) {
            $has_required = TRUE;
            break;
        }
        if (Element::children($element[$child])) {
            return $this->hasAnyRequired($element[$child]);
        }
    }
    return $has_required;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.