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


PHP FormStateInterface::disableRedirect方法代码示例

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


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

示例1: submitForm

 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     if ($form_state->get('json')) {
         $form_state->setResponse(new JsonResponse($form_state->getValues()));
     } else {
         $form_state->disableRedirect();
     }
 }
开发者ID:sgtsaughter,项目名称:d8portfolio,代码行数:11,代码来源:FormTestCheckboxesZeroForm.php

示例2: submitForm

 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     if (!$form_state->isValueEmpty('redirection')) {
         if (!$form_state->isValueEmpty('destination')) {
             // The destination is a random URL, so we can't use routed URLs.
             // @todo Revist this in https://www.drupal.org/node/2418219.
             $form_state->setRedirectUrl(Url::fromUserInput('/' . $form_state->getValue('destination')));
         }
     } else {
         $form_state->disableRedirect();
     }
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:15,代码来源:FormTestRedirectForm.php

示例3: submitForm

 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     if (!$form_state->isValueEmpty('redirection')) {
         if (!$form_state->isValueEmpty('destination')) {
             // @todo Use Url::fromPath() once https://www.drupal.org/node/2351379 is
             //   resolved.
             $form_state->setRedirectUrl(Url::fromUri('base://' . $form_state->getValue('destination')));
         }
     } else {
         $form_state->disableRedirect();
     }
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:15,代码来源:FormTestRedirectForm.php

示例4: ajaxFormWrapper

 /**
  * Wrapper for handling AJAX forms.
  *
  * Wrapper around \Drupal\Core\Form\FormBuilderInterface::buildForm() to
  * handle some AJAX stuff automatically.
  * This makes some assumptions about the client.
  *
  * @param \Drupal\Core\Form\FormInterface|string $form_class
  *   The value must be one of the following:
  *   - The name of a class that implements \Drupal\Core\Form\FormInterface.
  *   - An instance of a class that implements \Drupal\Core\Form\FormInterface.
  * @param \Drupal\Core\Form\FormStateInterface $form_state
  *   The current state of the form.
  *
  * @return \Drupal\Core\Ajax\AjaxResponse|string|array
  *   Returns one of three possible values:
  *   - A \Drupal\Core\Ajax\AjaxResponse object.
  *   - The rendered form, as a string.
  *   - A render array with the title in #title and the rendered form in the
  *   #markup array.
  */
 protected function ajaxFormWrapper($form_class, FormStateInterface &$form_state)
 {
     /** @var \Drupal\Core\Render\RendererInterface $renderer */
     $renderer = \Drupal::service('renderer');
     // This won't override settings already in.
     if (!$form_state->has('rerender')) {
         $form_state->set('rerender', FALSE);
     }
     $ajax = $form_state->get('ajax');
     // Do not overwrite if the redirect has been disabled.
     if (!$form_state->isRedirectDisabled()) {
         $form_state->disableRedirect($ajax);
     }
     $form_state->disableCache();
     // Builds the form in a render context in order to ensure that cacheable
     // metadata is bubbled up.
     $render_context = new RenderContext();
     $callable = function () use($form_class, &$form_state) {
         return \Drupal::formBuilder()->buildForm($form_class, $form_state);
     };
     $form = $renderer->executeInRenderContext($render_context, $callable);
     if (!$render_context->isEmpty()) {
         BubbleableMetadata::createFromRenderArray($form)->merge($render_context->pop())->applyTo($form);
     }
     $output = $renderer->renderRoot($form);
     drupal_process_attached($form);
     // These forms have the title built in, so set the title here:
     $title = $form_state->get('title') ?: '';
     if ($ajax && (!$form_state->isExecuted() || $form_state->get('rerender'))) {
         // If the form didn't execute and we're using ajax, build up an
         // Ajax command list to execute.
         $response = new AjaxResponse();
         // Attach the library necessary for using the OpenModalDialogCommand and
         // set the attachments for this Ajax response.
         $form['#attached']['library'][] = 'core/drupal.dialog.ajax';
         $response->setAttachments($form['#attached']);
         $display = '';
         $status_messages = array('#type' => 'status_messages');
         if ($messages = $renderer->renderRoot($status_messages)) {
             $display = '<div class="views-messages">' . $messages . '</div>';
         }
         $display .= $output;
         $options = array('dialogClass' => 'views-ui-dialog', 'width' => '75%');
         $response->addCommand(new OpenModalDialogCommand($title, $display, $options));
         if ($section = $form_state->get('#section')) {
             $response->addCommand(new Ajax\HighlightCommand('.' . Html::cleanCssIdentifier($section)));
         }
         return $response;
     }
     return $title ? ['#title' => $title, '#markup' => $output] : $output;
 }
开发者ID:nsp15,项目名称:Drupal8,代码行数:72,代码来源:ViewsFormBase.php

示例5: resetForm

 public function resetForm(&$form, FormStateInterface $form_state)
 {
     // _SESSION is not defined for users who are not logged in.
     // If filters are not overridden, store the 'remember' settings on the
     // default display. If they are, store them on this display. This way,
     // multiple displays in the same view can share the same filters and
     // remember settings.
     $display_id = $this->view->display_handler->isDefaulted('filters') ? 'default' : $this->view->current_display;
     if (isset($_SESSION['views'][$this->view->storage->id()][$display_id])) {
         unset($_SESSION['views'][$this->view->storage->id()][$display_id]);
     }
     // Set the form to allow redirect.
     if (empty($this->view->live_preview) && !\Drupal::request()->isXmlHttpRequest()) {
         $form_state->disableRedirect(FALSE);
     } else {
         $form_state->setRebuild();
         $this->view->exposed_data = array();
     }
     $form_state->setRedirect('<current>');
     $form_state->setValues([]);
 }
开发者ID:318io,项目名称:318-io,代码行数:21,代码来源:ExposedFormPluginBase.php

示例6: disableRedirect

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

示例7: testDisableRedirect

 /**
  * @covers ::disableRedirect
  *
  * @dataProvider providerSingleBooleanArgument
  *
  * @param bool $no_redirect
  */
 public function testDisableRedirect($no_redirect)
 {
     $this->decoratedFormState->disableRedirect($no_redirect)->shouldBeCalled();
     $this->assertSame($this->formStateDecoratorBase, $this->formStateDecoratorBase->disableRedirect($no_redirect));
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:12,代码来源:FormStateDecoratorBaseTest.php


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