public static function MultiValue::addMoreAjax in SAML Authentication 4.x
Same name and namespace in other branches
- 8.3 src/Element/MultiValue.php \Drupal\samlauth\Element\MultiValue::addMoreAjax()
Ajax callback for the "Add another item" button.
Parameters
array $form: The build form.
\Drupal\Core\Form\FormStateInterface $form_state: The form state.
Return value
array|null The element.
See also
\Drupal\Core\Field\WidgetBase::addMoreAjax()
File
- src/
Element/ MultiValue.php, line 394
Class
- MultiValue
- Provides a multi-value form element.
Namespace
Drupal\samlauth\ElementCode
public static function addMoreAjax(array $form, FormStateInterface $form_state) : ?array {
$button = $form_state
->getTriggeringElement();
// Go one level up in the form, to the widgets container.
$element = NestedArray::getValue($form, array_slice($button['#array_parents'], 0, -1));
// Ensure the widget allows adding additional items.
if ($element['#cardinality'] != FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED) {
return NULL;
}
// Adding until #1091852 gets solved.
if (!empty($element['#description_suffix'])) {
$element['#description'] .= ' ' . $element['#description_suffix'];
}
return $element;
}