public function SalesforceMappingFormCrudBase::validateForm in Salesforce Suite 5.0.x
Same name and namespace in other branches
- 8.4 modules/salesforce_mapping_ui/src/Form/SalesforceMappingFormCrudBase.php \Drupal\salesforce_mapping_ui\Form\SalesforceMappingFormCrudBase::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
- modules/
salesforce_mapping_ui/ src/ Form/ SalesforceMappingFormCrudBase.php, line 368
Class
- SalesforceMappingFormCrudBase
- Salesforce Mapping Form base.
Namespace
Drupal\salesforce_mapping_ui\FormCode
public function validateForm(array &$form, FormStateInterface $form_state) {
$bundles = $this->bundleInfo
->getBundleInfo($form_state
->getValue('drupal_entity_type'));
if (empty($bundles[$form_state
->getValue('drupal_bundle')])) {
$form_state
->setErrorByName('drupal_bundle', $this
->t('Invalid bundle for entity type.'));
}
$button = $form_state
->getTriggeringElement();
if ($button['#id'] != $form['actions']['submit']['#id']) {
// Skip validation unless we hit the "save" button.
return;
}
parent::validateForm($form, $form_state);
if ($this->entity
->doesPull()) {
try {
$this->client
->query($this->entity
->getPullQuery());
} catch (\Exception $e) {
$form_state
->setError($form['pull']['pull_where_clause'], $this
->t('Test pull query returned an error. Please check logs for error details.'));
\Drupal::service('event_dispatcher')
->dispatch(new SalesforceErrorEvent($e), SalesforceEvents::ERROR);
}
}
}