public static function ProfileForm::submitForm in Entity Legal 8.2
Same name and namespace in other branches
- 4.0.x src/Plugin/EntityLegal/ProfileForm.php \Drupal\entity_legal\Plugin\EntityLegal\ProfileForm::submitForm()
- 3.0.x src/Plugin/EntityLegal/ProfileForm.php \Drupal\entity_legal\Plugin\EntityLegal\ProfileForm::submitForm()
Submit handler for user register form.
File
- src/
Plugin/ EntityLegal/ ProfileForm.php, line 45
Class
- ProfileForm
- Method class for displaying a checkbox on the user register form.
Namespace
Drupal\entity_legal\Plugin\EntityLegalCode
public static function submitForm(array &$form, FormStateInterface $form_state) {
/** @var \Drupal\entity_legal\EntityLegalDocumentInterface $document */
foreach ($form['#entity_legal']->documents as $document) {
if (!empty($form_state
->getValue([
'legal_' . $document
->id(),
]))) {
$published_version = $document
->getPublishedVersion();
$acceptance = \Drupal::entityTypeManager()
->getStorage(ENTITY_LEGAL_DOCUMENT_ACCEPTANCE_ENTITY_NAME)
->create([
'uid' => $form_state
->getValue('uid'),
'document_version_name' => $published_version
->id(),
]);
$acceptance
->save();
}
}
}