protected static function MultiValue::setRequiredProperty in SAML Authentication 4.x
Same name and namespace in other branches
- 8.3 src/Element/MultiValue.php \Drupal\samlauth\Element\MultiValue::setRequiredProperty()
Sets the required property for the delta being processed.
Parameters
array $elements: The array containing the child elements.
int $delta: The delta currently being processed.
bool $required: If the main element is required or not.
1 call to MultiValue::setRequiredProperty()
- MultiValue::processMultiValue in src/
Element/ MultiValue.php - Processes a multi-value form element.
File
- src/
Element/ MultiValue.php, line 439
Class
- MultiValue
- Provides a multi-value form element.
Namespace
Drupal\samlauth\ElementCode
protected static function setRequiredProperty(array &$elements, int $delta, bool $required) : void {
if ($delta === 0 && $required) {
// If any of the children is set as required, the first delta is already
// set correctly.
foreach ($elements as $element) {
if (isset($element['#required']) && $element['#required'] === TRUE) {
return;
}
}
// Set all children as required otherwise.
foreach ($elements as &$element) {
$element['#required'] = TRUE;
}
return;
}
// For every other delta or when the main element is marked as not required,
// none of the children should be required neither.
foreach ($elements as &$element) {
$element['#required'] = FALSE;
}
}