当前位置: 首页>>代码示例>>PHP>>正文


PHP EntityForm::validateForm方法代码示例

本文整理汇总了PHP中Drupal\Core\Entity\EntityForm::validateForm方法的典型用法代码示例。如果您正苦于以下问题:PHP EntityForm::validateForm方法的具体用法?PHP EntityForm::validateForm怎么用?PHP EntityForm::validateForm使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Drupal\Core\Entity\EntityForm的用法示例。


在下文中一共展示了EntityForm::validateForm方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: validateForm

 /**
  * {@inheritdoc}
  */
 public function validateForm(array &$form, FormStateInterface $form_state)
 {
     if ($form_state->getValue('stateFrom') === $form_state->getValue('stateTo')) {
         $form_state->setErrorByName('stateTo', $this->t('You cannot use the same state for both from and to.'));
     }
     parent::validateForm($form, $form_state);
 }
开发者ID:tedbow,项目名称:scheduled-updates-demo,代码行数:10,代码来源:ModerationStateTransitionForm.php

示例2: validateForm

 /**
  * {@inheritdoc}
  */
 public function validateForm(array &$form, FormStateInterface $form_state)
 {
     parent::validateForm($form, $form_state);
     if (isset($form['default_value'])) {
         $item = $form['#entity']->get($this->entity->getName());
         $item->defaultValuesFormValidate($form['default_value'], $form, $form_state);
     }
 }
开发者ID:ravibarnwal,项目名称:laraitassociate.in,代码行数:11,代码来源:FieldConfigEditForm.php

示例3: validateForm

 /**
  * {@inheritdoc}
  */
 public function validateForm(array &$form, FormStateInterface $form_state)
 {
     // Only run key provider settings validation if the form is being submitted
     if ($form_state->isSubmitted()) {
         $plugin = $this->manager->createInstance($form_state->getValue('key_provider'), []);
         $plugin->validateConfigurationForm($form, $form_state);
     }
     parent::validateForm($form, $form_state);
 }
开发者ID:rlhawk,项目名称:key,代码行数:12,代码来源:KeyForm.php

示例4: validateForm

 /**
  * Validates the values.
  */
 public function validateForm(array &$form, FormStateInterface $form_state)
 {
     parent::validateForm($form, $form_state);
     $values = $form_state->getValues();
     // Require non-empty ID.
     $id = trim($values['id']);
     if (empty($id)) {
         $form_state->setErrorByName('id', $this->t('Subtype names must not be empty'));
     }
 }
开发者ID:Jamesadamar,项目名称:programmers_guide_to_drupal,代码行数:13,代码来源:MyEntityTypeForm.php

示例5: validateForm

 /**
  * {@inheritdoc}
  */
 public function validateForm(array &$form, FormStateInterface $form_state)
 {
     parent::validateForm($form, $form_state);
     // Validate and each email recipient.
     $recipients = explode(',', $form_state->getValue('recipients'));
     foreach ($recipients as &$recipient) {
         $recipient = trim($recipient);
         if (!$this->emailValidator->isValid($recipient)) {
             $form_state->setErrorByName('recipients', $this->t('%recipient is an invalid email address.', array('%recipient' => $recipient)));
         }
     }
     $form_state->setValue('recipients', $recipients);
 }
开发者ID:sarahwillem,项目名称:OD8,代码行数:16,代码来源:ContactFormEditForm.php

示例6: validateForm

 /**
  * {@inheritdoc}
  */
 public function validateForm(array &$form, FormStateInterface $form_state)
 {
     parent::validateForm($form, $form_state);
     // The machine name field should already check to see if the requested
     // machine name is available.
     $pattern = trim($form_state->getValue('date_format_pattern'));
     foreach ($this->dateFormatStorage->loadMultiple() as $format) {
         if ($format->getPattern() == $pattern && $format->id() == $this->entity->id()) {
             drupal_set_message(t('The existing format/name combination has not been altered.'));
             continue;
         }
     }
 }
开发者ID:ravibarnwal,项目名称:laraitassociate.in,代码行数:16,代码来源:DateFormatFormBase.php

示例7: validateForm

 /**
  * {@inheritdoc}
  *
  * Button-level validation handlers are highly discouraged for entity forms,
  * as they will prevent entity validation from running. If the entity is going
  * to be saved during the form submission, this method should be manually
  * invoked from the button-level validation handler, otherwise an exception
  * will be thrown.
  */
 public function validateForm(array &$form, FormStateInterface $form_state)
 {
     parent::validateForm($form, $form_state);
     /** @var \Drupal\Core\Entity\ContentEntityInterface $entity */
     $entity = $this->buildEntity($form, $form_state);
     $violations = $entity->validate();
     // Remove violations of inaccessible fields and not edited fields.
     $violations->filterByFieldAccess($this->currentUser())->filterByFields(array_diff(array_keys($entity->getFieldDefinitions()), $this->getEditedFieldNames($form_state)));
     $this->flagViolations($violations, $form, $form_state);
     // The entity was validated.
     $entity->setValidationRequired(FALSE);
     $form_state->setTemporaryValue('entity_validated', TRUE);
     return $entity;
 }
开发者ID:nsp15,项目名称:Drupal8,代码行数:23,代码来源:ContentEntityForm.php

示例8: validateForm

 /**
  * {@inheritdoc}
  */
 public function validateForm(array &$form, FormStateInterface $form_state)
 {
     parent::validateForm($form, $form_state);
     /** @var \Drupal\crm_core_match\Matcher\MatcherConfigInterface $matcher */
     $matcher = $this->entity;
     /** @var \Drupal\crm_core_match\Plugin\crm_core_match\engine\MatchEngineInterface $plugin */
     if ($matcher->isNew()) {
         $plugin_id = $form_state->getValue('plugin_id');
         $plugin = crm_core_match_matcher_manager()->createInstance($plugin_id, $matcher->getConfiguration());
     } else {
         $plugin = $matcher->getPlugin();
     }
     $plugin->validateConfigurationForm($form, $form_state);
 }
开发者ID:jasonruyle,项目名称:crm_core,代码行数:17,代码来源:MatcherForm.php

示例9: validateForm

  public function validateForm(array &$form, FormStateInterface $form_state) {
    parent::validateForm($form, $form_state);

    $code = $form_state->getValue('code');
    $return = $this->serializer->deserializeForm($code);

    $fillpdf_form = $return['form'];
    $fields = $return['fields'];

    if (!is_object($fillpdf_form) || !count($fields)) {
      $form_state->setErrorByName('code', $this->t('There was a problem processing your FillPDF form code. Please do a fresh export from the source and try pasting it again.'));
    }
    else {
      $form_state->setValue('mappings', [
        'form' => $fillpdf_form,
        'fields' => $fields,
      ]);
    }
  }
开发者ID:AshishNaik021,项目名称:iimisac-d8,代码行数:19,代码来源:FillPdfFormImportForm.php

示例10: validateForm

 /**
  * {@inheritdoc}
  */
 public function validateForm(array &$form, FormStateInterface $form_state)
 {
     parent::validateForm($form, $form_state);
     // Validate and each email recipient.
     $recipients = explode(',', $form_state->getValue('recipients'));
     foreach ($recipients as &$recipient) {
         $recipient = trim($recipient);
         if (!$this->emailValidator->isValid($recipient)) {
             $form_state->setErrorByName('recipients', $this->t('%recipient is an invalid email address.', array('%recipient' => $recipient)));
         }
     }
     $form_state->setValue('recipients', $recipients);
     $redirect_url = $form_state->getValue('redirect');
     if ($redirect_url && $this->pathValidator->isValid($redirect_url)) {
         if (Unicode::substr($redirect_url, 0, 1) !== '/') {
             $form_state->setErrorByName('redirect', $this->t('The path should start with /.'));
         }
     }
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:22,代码来源:ContactFormEditForm.php

示例11: validateForm

 /**
  * {@inheritdoc}
  */
 public function validateForm(array &$form, FormStateInterface $form_state)
 {
     parent::validateForm($form, $form_state);
     $this->plugin->validateConfigurationForm($form['settings'], $form_state);
 }
开发者ID:justincletus,项目名称:webdrupalpro,代码行数:8,代码来源:PaymentMethodForm.php

示例12: validateForm

 /**
  * {@inheritdoc}
  */
 public function validateForm(array &$form, FormStateInterface $form_state)
 {
     parent::validateForm($form, $form_state);
     // Only validate on edit.
     if ($form_state->hasValue('keyed_styles')) {
         // Check if another breakpoint group is selected.
         if ($form_state->getValue('breakpoint_group') != $form_state->getCompleteForm()['breakpoint_group']['#default_value']) {
             // Remove the image style mappings since the breakpoint ID has changed.
             $form_state->unsetValue('keyed_styles');
         }
         // Check that at least 1 image style has been selected when using sizes.
         foreach ($form_state->getValue('keyed_styles') as $breakpoint_id => $multipliers) {
             foreach ($multipliers as $multiplier => $image_style_mapping) {
                 if ($image_style_mapping['image_mapping_type'] === 'sizes') {
                     if (empty($image_style_mapping['sizes'])) {
                         $form_state->setError($form['keyed_styles'][$breakpoint_id][$multiplier]['sizes'], 'Provide a value for the sizes attribute.');
                     }
                     if (empty(array_keys(array_filter($image_style_mapping['sizes_image_styles'])))) {
                         $form_state->setError($form['keyed_styles'][$breakpoint_id][$multiplier]['sizes_image_styles'], 'Select at least one image style.');
                     }
                 }
             }
         }
     }
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:28,代码来源:ResponsiveImageStyleForm.php

示例13: validateForm

 /**
  * {@inheritdoc}
  */
 public function validateForm(array &$form, FormStateInterface $form_state)
 {
     parent::validateForm($form, $form_state);
     // @todo Move trimming upstream.
     $format_format = trim($form_state->getValue('format'));
     $format_name = trim($form_state->getValue('name'));
     // Ensure that the values to be saved later are exactly the ones validated.
     $form_state->setValueForElement($form['format'], $format_format);
     $form_state->setValueForElement($form['name'], $format_name);
     $format_exists = $this->queryFactory->get('filter_format')->condition('format', $format_format, '<>')->condition('name', $format_name)->execute();
     if ($format_exists) {
         $form_state->setErrorByName('name', $this->t('Text format names must be unique. A format named %name already exists.', array('%name' => $format_name)));
     }
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:17,代码来源:FilterFormatFormBase.php

示例14: validateForm

 /**
  * {@inheritdoc}
  */
 public function validateForm(array &$form, FormStateInterface $form_state)
 {
     parent::validateForm($form, $form_state);
     $id = trim($form_state->getValue('type'));
     // '0' is invalid, since elsewhere we check it using empty().
     if ($id == '0') {
         $form_state->setErrorByName('type', $this->t("Invalid machine-readable name. Enter a name other than %invalid.", array('%invalid' => $id)));
     }
 }
开发者ID:justincletus,项目名称:webdrupalpro,代码行数:12,代码来源:SupportTicketTypeForm.php

示例15: validateForm

 /**
  * {@inheritdoc}
  */
 public function validateForm(array &$form, FormStateInterface $form_state)
 {
     parent::validateForm($form, $form_state);
     $facet_source_id = $form_state->getValue('facet_source_id');
     if (!is_null($facet_source_id) && $facet_source_id !== '') {
         /** @var \Drupal\facets\FacetSource\FacetSourcePluginInterface $facet_source */
         $facet_source = $this->getFacetSourcePluginManager()->createInstance($facet_source_id, ['facet' => $this->getEntity()]);
         $facet_source->validateConfigurationForm($form, $form_state);
     }
 }
开发者ID:nB-MDSO,项目名称:mdso-d8blog,代码行数:13,代码来源:FacetSettingsForm.php


注:本文中的Drupal\Core\Entity\EntityForm::validateForm方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。