public function RRSSBSettingsForm::validateForm in Ridiculously Responsive Social Sharing Buttons 8.2
Form validation 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 FormBase::validateForm
File
- src/
Form/ RRSSBSettingsForm.php, line 212
Class
- RRSSBSettingsForm
- RRSSB settings form.
Namespace
Drupal\rrssb\FormCode
public function validateForm(array &$form, FormStateInterface $form_state) {
parent::validateForm($form, $form_state);
$values = $form_state
->getValues();
foreach ($values['chosen'] as $name => $settings) {
if ($settings['enabled']) {
if ($values['follow'] && isset($settings['username']) && !$settings['username']) {
$form_state
->setErrorByName("chosen[{$name}][username]", $this
->t('You must set the username to use "Follow" button for @button', [
'@button' => $name,
]));
}
// If a button is enabled where there is no URL, we don't count that
// as an error, just don't show the button (@see rrssb_settings).
}
}
}