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


PHP FormStateInterface::hasValue方法代码示例

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


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

示例1: save

 /**
  * {@inheritdoc}
  */
 public function save(array $form, FormStateInterface $form_state)
 {
     if (!$form_state->hasValue('context')) {
         $form_state->setValue('context', xmlsitemap_get_current_context());
     }
     if ($form_state->hasValue(['context', 'language'])) {
         $language = $form_state->getValue(['context', 'language']);
         if ($language == LanguageInterface::LANGCODE_NOT_SPECIFIED) {
             $form_state->unsetValue(['context', 'language']);
         }
     }
     $context = $form_state->getValue('context');
     $this->entity->context = $context;
     $this->entity->label = $form_state->getValue('label');
     $this->entity->id = xmlsitemap_sitemap_get_context_hash($context);
     try {
         $status = $this->entity->save();
         if ($status == SAVED_NEW) {
             drupal_set_message($this->t('Saved the %label sitemap.', array('%label' => $this->entity->label())));
         } else {
             if ($status == SAVED_UPDATED) {
                 drupal_set_message($this->t('Updated the %label sitemap.', array('%label' => $this->entity->label())));
             }
         }
     } catch (EntityStorageException $ex) {
         drupal_set_message($this->t('There is another sitemap saved with the same context.'), 'error');
     }
     $form_state->setRedirect('xmlsitemap.admin_search');
 }
开发者ID:jeroenos,项目名称:jeroenos_d8.mypressonline.com,代码行数:32,代码来源:XmlSitemapForm.php

示例2: partialSubmitForm

 /**
  * {@inheritdoc}
  */
 public function partialSubmitForm(array &$form, FormStateInterface $form_state)
 {
     // The title has not been validated, thus its value - in case of the test case
     // an empty string - may not be set.
     if (!$form_state->hasValue('title') && $form_state->hasValue('test')) {
         drupal_set_message('Only validated values appear in the form values.');
     }
 }
开发者ID:neetumorwani,项目名称:blogging,代码行数:11,代码来源:FormTestLimitValidationErrorsForm.php

示例3: submitForm

  /**
   * Saves Schema.org mappings in \Drupal\node\NodeTypeForm.
   */
  public static function submitForm(array &$form, FormStateInterface $form_state) {
    if ($form_state->hasValue('types')) {
      $entity_type = $form_state->getFormObject()->getEntity();
      $mapping = rdf_get_mapping('node', $entity_type->id());
      if ($entity_type->isNew()) {
        $mapping = rdf_get_mapping('node', $form_state->getValue('types'));
      }

      if ($form_state->hasValue('types')) {
        $mapping->setBundleMapping(array('types' => array($form_state->getValue('types'))))
          ->save();
      }
    }
  }
开发者ID:eloiv,项目名称:botafoc.cat,代码行数:17,代码来源:ContentMappings.php

示例4: testHasValue

 /**
  * @covers ::hasValue
  */
 public function testHasValue()
 {
     $key = ['foo', 'bar'];
     $has = TRUE;
     $this->decoratedFormState->hasValue($key)->willReturn($has)->shouldBeCalled();
     $this->assertSame($has, $this->formStateDecoratorBase->hasValue($key));
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:10,代码来源:FormStateDecoratorBaseTest.php

示例5: processHorizontalTabs

 /**
  * Creates a group formatted as horizontal tabs.
  *
  * @param array $element
  *   An associative array containing the properties and children of the
  *   details element.
  * @param \Drupal\Core\Form\FormStateInterface $form_state
  *   The current state of the form.
  * @param bool $on_form
  *   Are the tabs rendered on a form or not.
  *
  * @return array
  *   The processed element.
  */
 public static function processHorizontalTabs(&$element, FormStateInterface $form_state, $on_form = TRUE)
 {
     // Inject a new details as child, so that form_process_details() processes
     // this details element like any other details.
     $element['group'] = array('#type' => 'details', '#theme_wrappers' => array(), '#parents' => $element['#parents']);
     // Add an invisible label for accessibility.
     if (!isset($element['#title'])) {
         $element['#title'] = t('Horizontal Tabs');
         $element['#title_display'] = 'invisible';
     }
     // Add required JavaScript and Stylesheet.
     $element['#attached']['library'][] = 'field_group/formatter.horizontal_tabs';
     // Only add forms library on forms.
     if ($on_form) {
         $element['#attached']['library'][] = 'core/drupal.form';
     }
     // The JavaScript stores the currently selected tab in this hidden
     // field so that the active tab can be restored the next time the
     // form is rendered, e.g. on preview pages or when form validation
     // fails.
     $name = implode('__', $element['#parents']);
     if ($form_state->hasValue($name . '__active_tab')) {
         $element['#default_tab'] = $form_state->getValue($name . '__active_tab');
     }
     $element[$name . '__active_tab'] = array('#type' => 'hidden', '#default_value' => $element['#default_tab'], '#attributes' => array('class' => array('horizontal-tabs-active-tab')));
     return $element;
 }
开发者ID:frankcr,项目名称:sftw8,代码行数:41,代码来源:HorizontalTabs.php

示例6: buildForm

 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state, PageInterface $page = NULL, $name = '')
 {
     $this->page = $page;
     $this->staticContext = $this->page->getStaticContext($name);
     // Allow the condition to add to the form.
     $form['label'] = ['#type' => 'textfield', '#title' => $this->t('Label'), '#default_value' => isset($this->staticContext['label']) ? $this->staticContext['label'] : '', '#required' => TRUE];
     $form['machine_name'] = ['#type' => 'machine_name', '#maxlength' => 64, '#required' => TRUE, '#machine_name' => ['exists' => [$this, 'contextExists'], 'source' => ['label']], '#default_value' => $name];
     $form['entity_type'] = ['#type' => 'select', '#title' => $this->t('Entity type'), '#options' => $this->entityManager->getEntityTypeLabels(TRUE), '#limit_validation_errors' => array(array('entity_type')), '#submit' => ['::rebuildSubmit'], '#executes_submit_callback' => TRUE, '#ajax' => array('callback' => '::updateEntityType', 'wrapper' => 'add-static-context-wrapper', 'method' => 'replace')];
     $entity = NULL;
     if ($form_state->hasValue('entity_type')) {
         $entity_type = $form_state->getValue('entity_type');
         if ($this->staticContext['value']) {
             $entity = $this->entityManager->loadEntityByUuid($entity_type, $this->staticContext['value']);
         }
     } elseif (!empty($this->staticContext['type'])) {
         list(, $entity_type) = explode(':', $this->staticContext['type']);
         $entity = $this->entityManager->loadEntityByUuid($entity_type, $this->staticContext['value']);
     } elseif ($this->entityManager->hasDefinition('node')) {
         $entity_type = 'node';
     } else {
         $entity_type = 'user';
     }
     $form['entity_type']['#default_value'] = $entity_type;
     $form['selection'] = ['#type' => 'entity_autocomplete', '#prefix' => '<div id="add-static-context-wrapper">', '#suffix' => '</div>', '#required' => TRUE, '#target_type' => $entity_type, '#default_value' => $entity, '#title' => $this->t('Select entity')];
     $form['actions'] = ['#type' => 'actions'];
     $form['actions']['submit'] = ['#type' => 'submit', '#value' => $this->submitButtonText(), '#button_type' => 'primary'];
     return $form;
 }
开发者ID:pulibrary,项目名称:recap,代码行数:31,代码来源:StaticContextFormBase.php

示例7: submitConfigurationForm

 /**
  * {@inheritdoc}
  */
 public function submitConfigurationForm(array &$form, FormStateInterface $form_state)
 {
     $this->configuration['negate'] = $form_state->getValue('negate');
     if ($form_state->hasValue('context_mapping')) {
         $this->setContextMapping($form_state->getValue('context_mapping'));
     }
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:10,代码来源:ConditionPluginBase.php

示例8: processVerticalTabs

 /**
  * Creates a group formatted as vertical tabs.
  *
  * @param array $element
  *   An associative array containing the properties and children of the
  *   details element.
  * @param \Drupal\Core\Form\FormStateInterface $form_state
  *   The current state of the form.
  * @param array $complete_form
  *   The complete form structure.
  *
  * @return array
  *   The processed element.
  */
 public static function processVerticalTabs(&$element, FormStateInterface $form_state, &$complete_form)
 {
     // Inject a new details as child, so that form_process_details() processes
     // this details element like any other details.
     $element['group'] = array('#type' => 'details', '#theme_wrappers' => array(), '#parents' => $element['#parents']);
     // Add an invisible label for accessibility.
     if (!isset($element['#title'])) {
         $element['#title'] = t('Vertical Tabs');
         $element['#title_display'] = 'invisible';
     }
     $element['#attached']['library'][] = 'core/drupal.vertical-tabs';
     // The JavaScript stores the currently selected tab in this hidden
     // field so that the active tab can be restored the next time the
     // form is rendered, e.g. on preview pages or when form validation
     // fails.
     $name = implode('__', $element['#parents']);
     if ($form_state->hasValue($name . '__active_tab')) {
         $element['#default_tab'] = $form_state->getValue($name . '__active_tab');
     }
     $element[$name . '__active_tab'] = array('#type' => 'hidden', '#default_value' => $element['#default_tab'], '#attributes' => array('class' => array('vertical-tabs-active-tab')));
     // Clean up the active tab value so it's not accidentally stored in
     // settings forms.
     $form_state->addCleanValueKey($name . '__active_tab');
     return $element;
 }
开发者ID:nstielau,项目名称:drops-8,代码行数:39,代码来源:VerticalTabs.php

示例9: applyQuote

 /**
  * Ajax callback: Manually applies a shipping quote to an order.
  */
 public function applyQuote($form, FormStateInterface $form_state)
 {
     if ($form_state->hasValue(['quotes', 'quote_option'])) {
         if ($order = $form_state->get('order')) {
             $quote_option = explode('---', $form_state->getValue(['quotes', 'quote_option']));
             $order->quote['method'] = $quote_option[0];
             $order->quote['accessorials'] = $quote_option[1];
             $method = ShippingQuoteMethod::load($quote_option[0]);
             $label = $method->label();
             $quote_option = $form_state->getValue(['quotes', 'quote_option']);
             $order->quote['rate'] = $form_state->getValue(['quotes', $quote_option, 'rate']);
             $result = db_query("SELECT line_item_id FROM {uc_order_line_items} WHERE order_id = :id AND type = :type", [':id' => $order->id(), ':type' => 'shipping']);
             if ($lid = $result->fetchField()) {
                 uc_order_update_line_item($lid, $label, $order->quote['rate']);
                 $form_state->set('uc_quote', array('lid' => $lid, 'title' => $label, 'amount' => $order->quote['rate']));
             } else {
                 uc_order_line_item_add($order->id(), 'shipping', $label, $order->quote['rate']);
             }
             // Save selected shipping
             uc_quote_uc_order_update($order);
             // Update line items.
             $order->line_items = $order->getLineItems();
             // @todo Still needed?
             $form_state->set('order', $order);
             $form_state->setRebuild();
             $form_state->set('quote_requested', FALSE);
         }
     }
 }
开发者ID:justincletus,项目名称:webdrupalpro,代码行数:32,代码来源:Quotes.php

示例10: submitForm

 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     $filters = dblog_filters();
     foreach ($filters as $name => $filter) {
         if ($form_state->hasValue($name)) {
             $_SESSION['dblog_overview_filter'][$name] = $form_state->getValue($name);
         }
     }
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:12,代码来源:DblogFilterForm.php

示例11: buildForm

 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $check_config = $this->config('uc_payment_pack.check.settings');
     $form['check_address_info'] = array('#markup' => '<div>' . t('Set the mailing address to display to customers who choose this payment method during checkout.') . '</div>');
     $form['uc_check_mailing_name'] = array('#type' => 'textfield', '#title' => t('Contact'), '#description' => t('Direct checks to a person or department.'), '#default_value' => $check_config->get('mailing_address.name'));
     $default_country = $check_config->get('mailing_address.country') ? $check_config->get('mailing_address.country') : $this->config('uc_store.settings')->get('address.country');
     $form['uc_check_address'] = array('#type' => 'uc_address', '#default_value' => array('uc_check_mailing_company' => $check_config->get('mailing_address.company'), 'uc_check_mailing_street1' => $check_config->get('mailing_address.street1'), 'uc_check_mailing_street2' => $check_config->get('mailing_address.street2'), 'uc_check_mailing_city' => $check_config->get('mailing_address.city'), 'uc_check_mailing_zone' => $check_config->get('mailing_address.zone'), 'uc_check_mailing_country' => $form_state->hasValue('uc_check_mailing_country') ? $form_state->getValue('uc_check_mailing_country') : $default_country, 'uc_check_mailing_postal_code' => $check_config->get('mailing_address.postal_code')), '#required' => FALSE, '#key_prefix' => 'uc_check_mailing');
     $form['uc_check_policy'] = array('#type' => 'textarea', '#title' => t('Check payment policy', [], ['context' => 'cheque']), '#description' => t('Instructions for customers on the checkout page.'), '#default_value' => $check_config->get('policy'), '#rows' => 3);
     return $form;
 }
开发者ID:pedrocones,项目名称:hydrotools,代码行数:13,代码来源:CheckSettingsForm.php

示例12: submitForm

 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     $filters = $this->translateFilters();
     foreach ($filters as $name => $filter) {
         if ($form_state->hasValue($name)) {
             $_SESSION['locale_translate_filter'][$name] = $form_state->getValue($name);
         }
     }
     $form_state->setRedirect('locale.translate_page');
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:13,代码来源:TranslateFilterForm.php

示例13: entityFormEntityBuild

 /**
  * {@inheritdoc}
  */
 public function entityFormEntityBuild($entity_type, EntityInterface $entity, array $form, FormStateInterface $form_state)
 {
     if ($form_state->hasValue('content_translation')) {
         $translation =& $form_state->getValue('content_translation');
         /** @var \Drupal\comment\CommentInterface $entity */
         $translation['status'] = $entity->isPublished();
         $translation['name'] = $entity->getAuthorName();
     }
     parent::entityFormEntityBuild($entity_type, $entity, $form, $form_state);
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:13,代码来源:CommentTranslationHandler.php

示例14: buildConfigurationForm

 /**
  * {@inheritdoc}
  */
 public function buildConfigurationForm(array $form, FormStateInterface $form_state)
 {
     $parents = ['table', $this->uuid(), 'form'];
     $entity_type = $form_state->hasValue(array_merge($parents, ['entity_type'])) ? $form_state->getValue(array_merge($parents, ['entity_type'])) : $this->configuration['entity_type'];
     $bundle = $form_state->hasValue(array_merge($parents, ['bundle', 'select'])) ? $form_state->getValue(array_merge($parents, ['bundle', 'select'])) : $this->configuration['bundle'];
     $definitions = $this->entityManager->getDefinitions();
     $entity_types = array_combine(array_keys($definitions), array_map(function (EntityTypeInterface $item) {
         return $item->getLabel();
     }, $definitions));
     $form['entity_type'] = ['#type' => 'select', '#title' => $this->t('Entity type'), '#options' => $entity_types, '#default_value' => $entity_type, '#ajax' => ['wrapper' => 'bundle-wrapper', 'callback' => [$this, 'updateBundle']]];
     $bundles = [];
     if ($entity_type) {
         $definitions = $this->entityManager->getBundleInfo($entity_type);
         $bundles = array_map(function ($item) {
             return $item['label'];
         }, $definitions);
     }
     $form['bundle'] = ['#type' => 'container', 'select' => ['#type' => 'select', '#title' => $this->t('Bundle'), '#options' => $bundles, '#default_value' => $bundle], '#attributes' => ['id' => 'bundle-wrapper']];
     return $form;
 }
开发者ID:jepster,项目名称:GaiaD8,代码行数:23,代码来源:EntityForm.php

示例15: entityFormEntityBuild

 /**
  * {@inheritdoc}
  */
 public function entityFormEntityBuild($entity_type, EntityInterface $entity, array $form, FormStateInterface $form_state)
 {
     if ($form_state->hasValue('content_translation')) {
         $translation =& $form_state->getValue('content_translation');
         $translation['status'] = $entity->isPublished();
         $account = $entity->uid->entity;
         $translation['uid'] = $account ? $account->id() : 0;
         $translation['created'] = format_date($entity->created->value, 'custom', 'Y-m-d H:i:s O');
     }
     parent::entityFormEntityBuild($entity_type, $entity, $form, $form_state);
 }
开发者ID:sarahwillem,项目名称:OD8,代码行数:14,代码来源:NodeTranslationHandler.php


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