public static function Registrants::submitArityChange in RNG - Events and Registrations 8
For_arity radios submission handler.
Parameters
array $form:
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
File
- src/
Element/ Registrants.php, line 862
Class
- Registrants
- Provides a form element for a registrant and person association.
Namespace
Drupal\rng\ElementCode
public static function submitArityChange(array $form, FormStateInterface $form_state) {
$form_state
->setRebuild();
$trigger = $form_state
->getTriggeringElement();
$element = RegistrantsElement::findElement($form, $form_state);
$utility = new RegistrantsElement($element, $form_state);
/** @var \Drupal\rng\RegistrantInterface[] $people */
$people = $element['#value'];
$new_arity = $trigger['#value'];
$utility
->setArity($new_arity);
if (count($people) > 0) {
if ($new_arity === 'single') {
$utility
->clearPeopleFormInput();
$utility
->setForBundleAsFirstRegistrant();
}
else {
$utility
->clearPeopleFormInput();
$parents = array_merge($element['#parents'], [
'entities',
'for_bundle',
]);
NestedArray::unsetValue($form_state
->getUserInput(), $parents);
}
}
}