當前位置: 首頁>>代碼示例>>PHP>>正文


PHP FormStateInterface::isRedirectDisabled方法代碼示例

本文整理匯總了PHP中Drupal\Core\Form\FormStateInterface::isRedirectDisabled方法的典型用法代碼示例。如果您正苦於以下問題:PHP FormStateInterface::isRedirectDisabled方法的具體用法?PHP FormStateInterface::isRedirectDisabled怎麽用?PHP FormStateInterface::isRedirectDisabled使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Drupal\Core\Form\FormStateInterface的用法示例。


在下文中一共展示了FormStateInterface::isRedirectDisabled方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: 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

示例2: isRedirectDisabled

 /**
  * {@inheritdoc}
  */
 public function isRedirectDisabled()
 {
     return $this->decoratedFormState->isRedirectDisabled();
 }
開發者ID:eigentor,項目名稱:tommiblog,代碼行數:7,代碼來源:FormStateDecoratorBase.php

示例3: isRedirectDisabled

 /**
  * {@inheritdoc}
  */
 public function isRedirectDisabled()
 {
     return $this->mainFormState->isRedirectDisabled();
 }
開發者ID:Laudanum,項目名稱:authorization,代碼行數:7,代碼來源:SubFormState.php

示例4: testIsRedirectDisabled

 /**
  * @covers ::isRedirectDisabled
  *
  * @dataProvider providerSingleBooleanArgument
  *
  * @param bool $no_redirect
  */
 public function testIsRedirectDisabled($no_redirect)
 {
     $this->decoratedFormState->isRedirectDisabled()->willReturn($no_redirect)->shouldBeCalled();
     $this->assertSame($no_redirect, $this->formStateDecoratorBase->isRedirectDisabled());
 }
開發者ID:eigentor,項目名稱:tommiblog,代碼行數:12,代碼來源:FormStateDecoratorBaseTest.php


注:本文中的Drupal\Core\Form\FormStateInterface::isRedirectDisabled方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。