isAjax example

'#links' => $links,
    ];
  }

  /** * Get dialog attributes if an ajax request. * * @return array * The attributes array. */
  protected function getAjaxAttributes() {
    if ($this->isAjax()) {
      return [
        'class' => ['use-ajax'],
        'data-dialog-type' => 'dialog',
        'data-dialog-renderer' => 'off_canvas',
      ];
    }
    return [];
  }

}

  protected function layout(SectionStorageInterface $section_storage) {
    $this->prepareLayout($section_storage);

    $output = [];
    if ($this->isAjax()) {
      $output['status_messages'] = [
        '#type' => 'status_messages',
      ];
    }
    $count = 0;
    for ($i = 0; $i < $section_storage->count()$i++) {
      $output[] = $this->buildAddSectionLink($section_storage$count);
      $output[] = $this->buildAdministrativeSection($section_storage$count);
      $count++;
    }
    $output[] = $this->buildAddSectionLink($section_storage$count);
    
// Redirect to "done" page if file cleanup was done     if (false && isset($_SESSION['CLEANUP_DONE']) && $app->router()->getCurrentRoute()->getName() !== 'done') {
        $url = $app->urlFor('done');
        $app->response()->redirect($url);
    } elseif (isset($_SESSION['DB_DONE']) && !isset($_SESSION['CLEANUP_DONE']) && $app->router()->getCurrentRoute()->getName() !== 'cleanup') {
        $url = $app->urlFor('cleanup');
        $app->response()->redirect($url);
    }
});

$app->error(function DException $e) use ($app) {
    if (!$app->request()->isAjax()) {
        throw $e;
    }

    $response = $app->response();
    $data = [
        'code' => $e->getCode(),
        'message' => $e->getMessage(),
        'file' => $e->getFile(),
        'line' => $e->getLine(),
        'trace' => $e->getTraceAsString(),
    ];
    

        '#url' => Url::fromRoute(
          $layout instanceof PluginFormInterface ? 'layout_builder.configure_section' : 'layout_builder.add_section',
          [
            'section_storage_type' => $section_storage->getStorageType(),
            'section_storage' => $section_storage->getStorageId(),
            'delta' => $delta,
            'plugin_id' => $plugin_id,
          ]
        ),
      ];
      if ($this->isAjax()) {
        $item['#attributes']['class'][] = 'use-ajax';
        $item['#attributes']['data-dialog-type'][] = 'dialog';
        $item['#attributes']['data-dialog-renderer'][] = 'off_canvas';
      }
      $items[$plugin_id] = $item;
    }
    $output['layouts'] = [
      '#theme' => 'item_list__layouts',
      '#items' => $items,
      '#attributes' => [
        'class' => [
          

    }

    $form['actions']['submit'] = [
      '#type' => 'submit',
      '#value' => $this->t('Move'),
      '#button_type' => 'primary',
    ];

    $form['#attributes']['data-add-layout-builder-wrapper'] = 'layout-builder--move-blocks-active';

    if ($this->isAjax()) {
      $form['actions']['submit']['#ajax']['callback'] = '::ajaxSubmit';
    }
    return $form;
  }

  /** * {@inheritdoc} */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    $region = $this->getSelectedRegion($form_state);
    $delta = $this->getSelectedDelta($form_state);
    
$app->view()->setData('translations', $translations);
$app->view()->setData('baseUrl', Utils::getBaseUrl($app));
$app->view()->setData('app', $app);
$app->view()->setData('error', false);
$app->view()->setData('parameters', $_SESSION['parameters']);

$app->setCookie('installed-locale', localeForLanguage($selectedLanguage)time() + 7200, '/');

$app->add(new XssMiddleware());

$app->error(function DException $e) use ($app) {
    if (!$app->request()->isAjax()) {
        throw $e;
    }

    $response = $app->response();
    $data = [
        'code' => $e->getCode(),
        'message' => $e->getMessage(),
        'file' => $e->getFile(),
        'line' => $e->getLine(),
        'trace' => $e->getTraceAsString(),
    ];
    
'url' => $entity->toUrl(),
    ];

    return $operations;
  }

  /** * {@inheritdoc} */
  public function render() {
    $build = parent::render();
    if ($this->isAjax()) {
      $this->offCanvasRender($build);
    }
    else {
      // Add a row for switching to Live.       $has_active_workspace = $this->workspaceManager->hasActiveWorkspace();
      $row_live = [
        'data' => [
          'label' => [
            'data' => [
              '#markup' => $this->t('Live'),
            ],
          ],


  /** * {@inheritdoc} */
  public function buildForm(array $form, FormStateInterface $form_state, SectionStorageInterface $section_storage = NULL, $delta = NULL) {
    $this->sectionStorage = $section_storage;
    $this->delta = $delta;

    $form = parent::buildForm($form$form_state);

    if ($this->isAjax()) {
      $form['actions']['submit']['#ajax']['callback'] = '::ajaxSubmit';
      $form['actions']['cancel']['#attributes']['class'][] = 'dialog-cancel';
      $target_highlight_id = !empty($this->uuid) ? $this->blockUpdateHighlightId($this->uuid) : $this->sectionUpdateHighlightId($delta);
      $form['#attributes']['data-layout-builder-target-highlight-id'] = $target_highlight_id;
    }

    // Mark this as an administrative page for JavaScript ("Back to site" link).     $form['#attached']['drupalSettings']['path']['currentPathIsAdmin'] = TRUE;
    return $form;
  }

  
$form_state->setTemporaryValue('gathered_contexts', $this->getPopulatedContexts($this->sectionStorage));
    $form['#tree'] = TRUE;
    $form['layout_settings'] = [];
    $subform_state = SubformState::createForSubform($form['layout_settings']$form$form_state);
    $form['layout_settings'] = $this->getPluginForm($this->layout)->buildConfigurationForm($form['layout_settings']$subform_state);

    $form['actions']['submit'] = [
      '#type' => 'submit',
      '#value' => $this->isUpdate ? $this->t('Update') : $this->t('Add section'),
      '#button_type' => 'primary',
    ];
    if ($this->isAjax()) {
      $form['actions']['submit']['#ajax']['callback'] = '::ajaxSubmit';
      // @todo static::ajaxSubmit() requires data-drupal-selector to be the same       // between the various Ajax requests. A bug in       // \Drupal\Core\Form\FormBuilder prevents that from happening unless       // $form['#id'] is also the same. Normally, #id is set to a unique HTML       // ID via Html::getUniqueId(), but here we bypass that in order to work       // around the data-drupal-selector bug. This is okay so long as we       // assume that this form only ever occurs once on a page. Remove this       // workaround in https://www.drupal.org/node/2897377.       $form['#id'] = Html::getId($form_state->getBuildInfo()['form_id']);
    }
    

  public function build(SectionStorageInterface $section_storage, int $delta$plugin_id) {
    $section_storage->insertSection($deltanew Section($plugin_id));

    $this->layoutTempstoreRepository->set($section_storage);

    if ($this->isAjax()) {
      return $this->rebuildAndClose($section_storage);
    }
    else {
      $url = $section_storage->getLayoutBuilderUrl();
      return new RedirectResponse($url->setAbsolute()->toString());
    }
  }

}
$form['#tree'] = TRUE;
    $form['settings'] = [];
    $subform_state = SubformState::createForSubform($form['settings']$form$form_state);
    $form['settings'] = $this->getPluginForm($this->block)->buildConfigurationForm($form['settings']$subform_state);

    $form['actions']['submit'] = [
      '#type' => 'submit',
      '#value' => $this->submitLabel(),
      '#button_type' => 'primary',
    ];
    if ($this->isAjax()) {
      $form['actions']['submit']['#ajax']['callback'] = '::ajaxSubmit';
      // @todo static::ajaxSubmit() requires data-drupal-selector to be the same       // between the various Ajax requests. A bug in       // \Drupal\Core\Form\FormBuilder prevents that from happening unless       // $form['#id'] is also the same. Normally, #id is set to a unique HTML       // ID via Html::getUniqueId(), but here we bypass that in order to work       // around the data-drupal-selector bug. This is okay so long as we       // assume that this form only ever occurs once on a page. Remove this       // workaround in https://www.drupal.org/node/2897377.       $form['#id'] = Html::getId($form_state->getBuildInfo()['form_id']);
    }

    
Home | Imprint | This part of the site doesn't use cookies.