/** * {@inheritdoc} */ public function validateForm(array &$form, FormStateInterface $form_state) { parent::validateForm($form, $form_state); // Ensure each path is unique. $path = $this->entityQuery->get('search_page')->condition('path', $form_state->getValue('path'))->condition('id', $form_state->getValue('id'), '<>')->execute(); if ($path) { $form_state->setErrorByName('path', $this->t('The search page path must be unique.')); } if ($this->plugin instanceof PluginFormInterface) { $this->plugin->validateConfigurationForm($form, $form_state); } }
/** * {@inheritdoc} */ public function validate(array $form, array &$form_state) { parent::validate($form, $form_state); // Ensure each path is unique. $path = $this->entityQuery->get('search_page')->condition('path', $form_state['values']['path'])->condition('id', $form_state['values']['id'], '<>')->execute(); if ($path) { $this->setFormError('path', $form_state, $this->t('The search page path must be unique.')); } if ($this->plugin instanceof PluginFormInterface) { $this->plugin->validateConfigurationForm($form, $form_state); } }