public function BynderConfigurationForm::validateForm in Bynder 4.0.x
Same name and namespace in other branches
- 8.3 src/Form/BynderConfigurationForm.php \Drupal\bynder\Form\BynderConfigurationForm::validateForm()
- 8 src/Form/BynderConfigurationForm.php \Drupal\bynder\Form\BynderConfigurationForm::validateForm()
- 8.2 src/Form/BynderConfigurationForm.php \Drupal\bynder\Form\BynderConfigurationForm::validateForm()
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/ BynderConfigurationForm.php, line 387
Class
- BynderConfigurationForm
- Configure bynder to enable OAuth based access.
Namespace
Drupal\bynder\FormCode
public function validateForm(array &$form, FormStateInterface $form_state) {
$credentials = $form_state
->getValue('credentials');
// Makes sure we don't have a leading slash in the domain url.
$credentials['account_domain'] = rtrim($credentials['account_domain'], '/');
$form_state
->setValue([
'credentials',
'account_domain',
], $credentials['account_domain']);
if ($form_state
->getValue('test_connection')) {
if (!$form_state::hasAnyErrors() && !$this
->testApiConnection($credentials['permanent_token'], $credentials['account_domain'])) {
$form_state
->setErrorByName('credentials', $this
->t('Could not establish connection with Bynder. Check your credentials or <a href=":support">contact support.</a>', [
':support' => 'mailto:support@getbynder.com',
]));
}
}
parent::validateForm($form, $form_state);
}