public function ContributeSettingsForm::submitForm in Contribute 8
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 ConfigFormBase::submitForm
File
- src/
Form/ ContributeSettingsForm.php, line 206
Class
- ContributeSettingsForm
- Configure contribute settings for this site.
Namespace
Drupal\contribute\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
if ((string) $form_state
->getValue('op') === (string) $this
->t('Clear')) {
$status = TRUE;
$account_type = NULL;
$account_id = NULL;
$this
->messenger()
->addMessage($this
->t('Community information has been cleared.'));
}
elseif ($form_state
->getValue('disable')) {
$status = FALSE;
$account_type = NULL;
$account_id = NULL;
$this
->messenger()
->addMessage($this
->t('Community information has been disabled.'));
}
else {
$status = TRUE;
$account_type = $form_state
->getValue('account_type');
$account_id = $form_state
->getValue($account_type . '_id');
$this
->messenger()
->addMessage($this
->t('Your community information has been saved.'));
}
// Always clear cached information.
Cache::invalidateTags([
'contribute',
]);
$this
->config('contribute.settings')
->set('status', $status)
->set('account_type', $account_type)
->set('account_id', $account_id)
->save();
$form_state
->setRedirect('system.status');
}