public function SamlauthMappingEditForm::submitForm in SAML Authentication 8.3
Same name and namespace in other branches
- 4.x modules/samlauth_user_fields/src/Form/SamlauthMappingEditForm.php \Drupal\samlauth_user_fields\Form\SamlauthMappingEditForm::submitForm()
Form submission handler.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Overrides FormInterface::submitForm
File
- modules/
samlauth_user_fields/ src/ Form/ SamlauthMappingEditForm.php, line 219
Class
- SamlauthMappingEditForm
- Form for adding a mapped SAML attribute -> user field.
Namespace
Drupal\samlauth_user_fields\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$config = $this
->configFactory()
->getEditable(UserFieldsEventSubscriber::CONFIG_OBJECT_NAME);
$mappings = $config
->get('field_mappings');
$new_mapping = [
'attribute_name' => $form_state
->getValue('attribute_name'),
'field_name' => $form_state
->getValue('field_name'),
'link_user_order' => $form_state
->getValue('link_user_order'),
];
$mapping_id = $form_state
->getValue('mapping_id');
if (!is_array($mappings)) {
$mappings = [];
}
if ($mapping_id !== NULL) {
$mappings[$mapping_id] = $new_mapping;
}
else {
$mappings[] = $new_mapping;
}
$config
->set('field_mappings', $mappings)
->save();
$form_state
->setRedirect('samlauth_user_fields.list');
}