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


PHP FormStateInterface::getSubmitHandlers方法代码示例

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


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

示例1: buildChildFormState

  /**
   * Build all necessary things for child form (form state, etc.).
   *
   * @param \Drupal\Core\Entity\EntityFormInterface $controller
   *   Entity form controller for child form.
   * @param \Drupal\Core\Form\FormStateInterface $form_state
   *   Parent form state object.
   * @param \Drupal\Core\Entity\EntityInterface $entity
   *   Entity object.
   * @param string $operation
   *   Operation that is to be performed in inline form.
   * @param array $parents
   *   Entity form #parents.
   *
   * @return \Drupal\Core\Form\FormStateInterface
   *   Child form state object.
   */
  public static function buildChildFormState(EntityFormInterface $controller, FormStateInterface $form_state, EntityInterface $entity, $operation, $parents) {
    $child_form_state = new FormState();

    $child_form_state->addBuildInfo('callback_object', $controller);
    $child_form_state->addBuildInfo('base_form_id', $controller->getBaseFormID());
    $child_form_state->addBuildInfo('form_id', $controller->getFormID());
    $child_form_state->addBuildInfo('args', array());

    // Copy values to child form.
    $child_form_state->setCompleteForm($form_state->getCompleteForm());
    $child_form_state->setUserInput($form_state->getUserInput());

    // Filter out all submitted values that are not directly relevant for this
    // IEF. Otherwise they might mess things up.
    $form_state_values = $form_state->getValues();
    $form_state_values = static::extractArraySequence($form_state_values, $parents);

    $child_form_state->setValues($form_state_values);
    $child_form_state->setStorage($form_state->getStorage());
    $value = \Drupal::entityTypeManager()->getStorage('entity_form_display')->load($entity->getEntityTypeId() . '.' . $entity->bundle() . '.' . $operation);
    $child_form_state->set('form_display', $value);

    // Since some of the submit handlers are run, redirects need to be disabled.
    $child_form_state->disableRedirect();

    // When a form is rebuilt after Ajax processing, its #build_id and #action
    // should not change.
    // @see drupal_rebuild_form()
    $rebuild_info = $child_form_state->getRebuildInfo();
    $rebuild_info['copy']['#build_id'] = TRUE;
    $rebuild_info['copy']['#action'] = TRUE;
    $child_form_state->setRebuildInfo($rebuild_info);

    $child_form_state->set('inline_entity_form', $form_state->get('inline_entity_form'));
    $child_form_state->set('langcode', $entity->language()->getId());

    $child_form_state->set('field', $form_state->get('field'));
    $child_form_state->setTriggeringElement($form_state->getTriggeringElement());
    $child_form_state->setSubmitHandlers($form_state->getSubmitHandlers());

    return $child_form_state;
  }
开发者ID:joebachana,项目名称:usatne,代码行数:59,代码来源:EntityInlineForm.php

示例2: executeSubmitHandlers

 /**
  * {@inheritdoc}
  */
 public function executeSubmitHandlers(&$form, FormStateInterface &$form_state)
 {
     // If there was a button pressed, use its handlers.
     $handlers = $form_state->getSubmitHandlers();
     // Otherwise, check for a form-level handler.
     if (!$handlers && !empty($form['#submit'])) {
         $handlers = $form['#submit'];
     }
     foreach ($handlers as $callback) {
         // Check if a previous _submit handler has set a batch, but make sure we
         // do not react to a batch that is already being processed (for instance
         // if a batch operation performs a
         //  \Drupal\Core\Form\FormBuilderInterface::submitForm()).
         if (($batch =& $this->batchGet()) && !isset($batch['id'])) {
             // Some previous submit handler has set a batch. To ensure correct
             // execution order, store the call in a special 'control' batch set.
             // See _batch_next_set().
             $batch['sets'][] = array('form_submit' => $callback);
             $batch['has_form_submits'] = TRUE;
         } else {
             call_user_func_array($form_state->prepareCallback($callback), array(&$form, &$form_state));
         }
     }
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:27,代码来源:FormSubmitter.php

示例3: getSubmitHandlers

 /**
  * {@inheritdoc}
  */
 public function getSubmitHandlers()
 {
     return $this->mainFormState->getSubmitHandlers();
 }
开发者ID:Laudanum,项目名称:authorization,代码行数:7,代码来源:SubFormState.php

示例4: buildChildFormState

 /**
  * Build all necessary things for child form (form state, etc.).
  *
  * @param \Drupal\Core\Entity\EntityFormInterface $controller
  *   Entity form controller for child form.
  * @param \Drupal\Core\Form\FormStateInterface $form_state
  *   Parent form state object.
  * @param \Drupal\Core\Entity\EntityInterface $entity
  *   Entity object.
  * @param string $operation
  *   Operation that is to be performed in inline form.
  *
  * @return \Drupal\Core\Form\FormStateInterface
  *   Child form state object.
  */
 public static function buildChildFormState(EntityFormInterface $controller, FormStateInterface $form_state, EntityInterface $entity, $operation)
 {
     $child_form_state = new FormState();
     $child_form_state->addBuildInfo('callback_object', $controller);
     $child_form_state->addBuildInfo('base_form_id', $controller->getBaseFormID());
     $child_form_state->addBuildInfo('form_id', $controller->getFormID());
     $child_form_state->addBuildInfo('args', array());
     // Copy values to child form.
     $child_form_state->setUserInput($form_state->getUserInput());
     $child_form_state->setValues($form_state->getValues());
     $child_form_state->setStorage($form_state->getStorage());
     $child_form_state->set('form_display', entity_get_form_display($entity->getEntityTypeId(), $entity->bundle(), $operation));
     // Since some of the submit handlers are run, redirects need to be disabled.
     $child_form_state->disableRedirect();
     // When a form is rebuilt after Ajax processing, its #build_id and #action
     // should not change.
     // @see drupal_rebuild_form()
     $rebuild_info = $child_form_state->getRebuildInfo();
     $rebuild_info['copy']['#build_id'] = TRUE;
     $rebuild_info['copy']['#action'] = TRUE;
     $child_form_state->setRebuildInfo($rebuild_info);
     $child_form_state->set('inline_entity_form', $form_state->get('inline_entity_form'));
     $child_form_state->set('langcode', $entity->language()->getId());
     $child_form_state->set('field', $form_state->get('field'));
     $child_form_state->setTriggeringElement($form_state->getTriggeringElement());
     $child_form_state->setSubmitHandlers($form_state->getSubmitHandlers());
     return $child_form_state;
 }
开发者ID:atif-shaikh,项目名称:DCX-Profile,代码行数:43,代码来源:EntityInlineEntityFormHandler.php

示例5: validateForm

 /**
  * {@inheritdoc}
  */
 public function validateForm(array &$form, FormStateInterface $form_state)
 {
     $mail = $form_state->getValue(array('mail', 0, 'value'));
     // Users should login to manage their subscriptions.
     if (\Drupal::currentUser()->isAnonymous() && ($user = user_load_by_mail($mail))) {
         $message = $user->isBlocked() ? $this->t('The email address %mail belongs to a blocked user.', array('%mail' => $mail)) : $this->t('There is an account registered for the e-mail address %mail. Please log in to manage your newsletter subscriptions.', array('%mail' => $mail));
         $form_state->setErrorByName('mail', $message);
     }
     // Unless the submit handler is 'update', if the newsletter checkboxes are
     // available, at least one must be checked.
     $update = in_array('::submitUpdate', $form_state->getSubmitHandlers());
     if (!$update && !$this->getSubscriptionWidget($form_state)->isHidden() && !count($form_state->getValue('subscriptions'))) {
         $form_state->setErrorByName('subscriptions', t('You must select at least one newsletter.'));
     }
     parent::validateForm($form, $form_state);
 }
开发者ID:aritnath1990,项目名称:simplenewslatest,代码行数:19,代码来源:SubscriptionsFormBase.php

示例6: getSubmitHandlers

 /**
  * {@inheritdoc}
  */
 public function getSubmitHandlers()
 {
     return $this->decoratedFormState->getSubmitHandlers();
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:7,代码来源:FormStateDecoratorBase.php

示例7: testGetSubmitHandlers

 /**
  * @covers ::getSubmitHandlers
  */
 public function testGetSubmitHandlers()
 {
     $submit_handlers = ['FOO' => 'BAR'];
     $this->decoratedFormState->getSubmitHandlers()->willReturn($submit_handlers)->shouldBeCalled();
     $this->assertSame($submit_handlers, $this->formStateDecoratorBase->getSubmitHandlers());
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:9,代码来源:FormStateDecoratorBaseTest.php


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