public function GoogleApiServiceClientForm::validateForm in Google API PHP Client 8.4
Same name and namespace in other branches
- 8.3 src/Form/GoogleApiServiceClientForm.php \Drupal\google_api_client\Form\GoogleApiServiceClientForm::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/ GoogleApiServiceClientForm.php, line 138
Class
- GoogleApiServiceClientForm
- Form controller for the google_api_service_client entity edit forms.
Namespace
Drupal\google_api_client\FormCode
public function validateForm(array &$form, FormStateInterface $form_state) {
$auth_config = $form_state
->getValue('auth_config');
if ($auth_config_obj = Json::decode($auth_config)) {
if (!isset($auth_config_obj['type']) || $auth_config_obj['type'] != 'service_account') {
$form_state
->setErrorByName('auth_config', $this
->t('Invalid key file, this configuration needs a service account key, if you are using oauth goto Google api client listing.'));
}
}
else {
// Json decode failed so json is invalid.
$form_state
->setErrorByName('auth_config', $this
->t('Invalid Json, paste complete file contents as downloaded.'));
}
parent::validateForm($form, $form_state);
}