buildOptionsForm example



    return $operators;
  }

  protected $valueFormType = 'select';

  protected function valueForm(&$form, FormStateInterface $form_state) {
    parent::valueForm($form$form_state);

    if (!$form_state->get('exposed')) {
      $this->helper->buildOptionsForm($form$form_state);
    }
  }

  /** * {@inheritdoc} */
  public function ensureMyTable() {
    // Defer to helper if the operator specifies it.     $info = $this->operators();
    if (isset($info[$this->operator]['ensure_my_table']) && $info[$this->operator]['ensure_my_table'] == 'helper') {
      return $this->helper->ensureMyTable();
    }

class UnformattedSummary extends DefaultSummary {

  protected function defineOptions() {
    $options = parent::defineOptions();
    $options['inline'] = ['default' => FALSE];
    $options['separator'] = ['default' => ''];
    return $options;
  }

  public function buildOptionsForm(&$form, FormStateInterface $form_state) {
    parent::buildOptionsForm($form$form_state);
    $form['inline'] = [
      '#type' => 'checkbox',
      '#default_value' => !empty($this->options['inline']),
      '#title' => $this->t('Display items inline'),
    ];
    $form['separator'] = [
      '#type' => 'textfield',
      '#title' => $this->t('Separator'),
      '#default_value' => $this->options['separator'],
    ];
  }

}

  protected function defineOptions() {
    $options = parent::defineOptions();
    $options['tokenize'] = ['default' => FALSE];
    return $options;
  }

  /** * {@inheritdoc} */
  public function buildOptionsForm(&$form, FormStateInterface $form_state) {
    parent::buildOptionsForm($form$form_state);

    // Add tokenization form elements.     $this->tokenForm($form$form_state);
  }

  /** * Adds tokenization form elements. */
  public function tokenForm(&$form, FormStateInterface $form_state) {
    $form['tokenize'] = [
      '#type' => 'checkbox',
      
protected function defineOptions() {
    $options = parent::defineOptions();
    $options['must_not_be'] = ['default' => FALSE];
    return $options;
  }

  /** * {@inheritdoc} */
  public function buildOptionsForm(&$form, FormStateInterface $form_state) {
    parent::buildOptionsForm($form$form_state);
    $form['must_not_be'] = [
      '#type' => 'checkbox',
      '#title' => $this->t('Fail basic validation if any argument is given'),
      '#default_value' => !empty($this->options['must_not_be']),
      '#description' => $this->t('By checking this field, you can use this to make sure views with more arguments than necessary fail validation.'),
      '#group' => 'options][more',
    ];

    unset($form['exception']);
  }

  
$options = parent::defineOptions();

    $options['granularity'] = ['default' => 2];

    return $options;
  }

  /** * {@inheritdoc} */
  public function buildOptionsForm(&$form, FormStateInterface $form_state) {
    parent::buildOptionsForm($form$form_state);

    $form['granularity'] = [
      '#type' => 'textfield',
      '#title' => $this->t('Granularity'),
      '#description' => $this->t('How many different units to display in the string.'),
      '#default_value' => $this->options['granularity'],
    ];
  }

  /** * {@inheritdoc} */

    $form_state = new FormState();
    $description_top = '<p>The handler for this item is broken or missing. The following details are available:</p>';
    $description_bottom = '<p>Enabling the appropriate module may solve this issue. Otherwise, check to see if there is a module update available.</p>';
    foreach ($types as $type => $class) {
      foreach ($items as $item) {
        $handler = $this->container->get('plugin.manager.views.' . $type)
          ->getHandler($item);
        $this->assertTrue($handler instanceof $class);
        // Make sure details available at edit form.         $form = [];
        $handler->buildOptionsForm($form$form_state);
        $this->assertEquals($description_top$form['description']['description_top']['#markup']);
        $this->assertEquals($description_bottom$form['description']['description_bottom']['#markup']);
        $details = [];
        foreach ($item as $key => $value) {
          $details[] = new FormattableMarkup('@key: @value', ['@key' => $key, '@value' => $value]);
        }
        $this->assertEquals($details$form['description']['detail_list']['#items']);
      }
    }

    $views_data = $this->viewsData();
    
$options['default_row_class'] = ['default' => TRUE];
    }
    $options['uses_fields'] = ['default' => FALSE];

    return $options;
  }

  /** * {@inheritdoc} */
  public function buildOptionsForm(&$form, FormStateInterface $form_state) {
    parent::buildOptionsForm($form$form_state);
    // Only fields-based views can handle grouping. Style plugins can also exclude     // themselves from being groupable by setting their "usesGrouping" property     // to FALSE.     // @TODO: Document "usesGrouping" in docs.php when docs.php is written.     if ($this->usesFields() && $this->usesGrouping()) {
      $options = ['' => $this->t('- None -')];
      $field_labels = $this->displayHandler->getFieldLabels(TRUE);
      $options += $field_labels;
      // If there are no fields, we can't group on them.       if (count($options) > 1) {
        // This is for backward compatibility, when there was just a single
$options = parent::defineOptions();

    $options['comments'] = ['default' => FALSE];

    return $options;
  }

  /** * {@inheritdoc} */
  public function buildOptionsForm(&$form, FormStateInterface $form_state) {
    parent::buildOptionsForm($form$form_state);
    if (\Drupal::moduleHandler()->moduleExists('comment')) {
      $form['comments'] = [
        '#type' => 'checkbox',
        '#title' => $this->t('Check for new comments as well'),
        '#default_value' => !empty($this->options['comments']),
      ];
    }
  }

  /** * {@inheritdoc} */
return $this->t($this->options['perm']);
  }

  protected function defineOptions() {
    $options = parent::defineOptions();
    $options['perm'] = ['default' => 'access content'];

    return $options;
  }

  public function buildOptionsForm(&$form, FormStateInterface $form_state) {
    parent::buildOptionsForm($form$form_state);
    // Get list of permissions     $perms = [];
    $permissions = $this->permissionHandler->getPermissions();
    foreach ($permissions as $perm => $perm_item) {
      $provider = $perm_item['provider'];
      $display_name = $this->moduleHandler->getName($provider);
      $perms[$display_name][$perm] = strip_tags($perm_item['title']);
    }

    $form['perm'] = [
      '#type' => 'select',
      
$executable = $view->getExecutable();
    if (!$executable->setDisplay($display_id)) {
      $form['markup'] = ['#markup' => $this->t('Invalid display id @display', ['@display' => $display_id])];
      return $form;
    }

    // Get form from the handler.     $form['options'] = [
      '#theme_wrappers' => ['container'],
      '#attributes' => ['class' => ['scroll'], 'data-drupal-views-scroll' => TRUE],
    ];
    $executable->display_handler->buildOptionsForm($form['options']$form_state);

    // The handler options form sets $form['#title'], which we need on the entire     // $form instead of just the ['options'] section.     $form['#title'] = $form['options']['#title'];
    unset($form['options']['#title']);

    // Move the override dropdown out of the scrollable section of the form.     if (isset($form['options']['override'])) {
      $form['override'] = $form['options']['override'];
      unset($form['options']['override']);
    }

    
$options['query_tags'] = [
      'default' => [],
    ];

    return $options;
  }

  /** * Add settings for the ui. */
  public function buildOptionsForm(&$form, FormStateInterface $form_state) {
    parent::buildOptionsForm($form$form_state);

    $form['disable_sql_rewrite'] = [
      '#title' => $this->t('Disable SQL rewriting'),
      '#description' => $this->t('Disabling SQL rewriting will omit all query tags, i. e. disable node access checks as well as override hook_query_alter() implementations in other modules.'),
      '#type' => 'checkbox',
      '#default_value' => !empty($this->options['disable_sql_rewrite']),
      '#suffix' => '<div class="messages messages--warning sql-rewrite-warning js-hide">' . $this->t('WARNING: Disabling SQL rewriting means that node access security is disabled. This may allow users to see data they should not be able to see if your view is misconfigured. Use this option only if you understand and accept this security risk.') . '</div>',
    ];
    $form['distinct'] = [
      '#type' => 'checkbox',
      '#title' => $this->t('Distinct'),
      

  protected function defineOptions() {
    $options = parent::defineOptions();
    $options['content'] = ['default' => ''];
    return $options;
  }

  /** * {@inheritdoc} */
  public function buildOptionsForm(&$form, FormStateInterface $form_state) {
    parent::buildOptionsForm($form$form_state);

    $form['content'] = [
      '#title' => $this->t('Content'),
      '#type' => 'textarea',
      '#description' => $this->t('You may enter data from this view as per the "Available global token replacements" above. You may include the following allowed HTML tags: <code>@tags</code>', [
        '@tags' => '<' . implode('> <', Xss::getAdminTagList()) . '>',
      ]),
      '#default_value' => $this->options['content'],
      '#rows' => 6,
    ];
  }

  
protected function defineOptions() {
    $options = parent::defineOptions();
    $options['argument'] = ['default' => ''];

    return $options;
  }

  /** * {@inheritdoc} */
  public function buildOptionsForm(&$form, FormStateInterface $form_state) {
    parent::buildOptionsForm($form$form_state);
    $form['argument'] = [
      '#type' => 'textfield',
      '#title' => $this->t('Fixed value'),
      '#default_value' => $this->options['argument'],
    ];
  }

  /** * {@inheritdoc} */
  public function getArgument() {
    
protected function defineOptions() {
    $options = parent::defineOptions();
    $options['results_lifespan'] = ['default' => 3600];
    $options['results_lifespan_custom'] = ['default' => 0];
    $options['output_lifespan'] = ['default' => 3600];
    $options['output_lifespan_custom'] = ['default' => 0];

    return $options;
  }

  public function buildOptionsForm(&$form, FormStateInterface $form_state) {
    parent::buildOptionsForm($form$form_state);
    $options = [60, 300, 1800, 3600, 21600, 518400];
    $options = array_map([$this->dateFormatter, 'formatInterval']array_combine($options$options));
    $options = [0 => $this->t('Never cache')] + $options + ['custom' => $this->t('Custom')];

    $form['results_lifespan'] = [
      '#type' => 'select',
      '#title' => $this->t('Query results'),
      '#description' => $this->t('The length of time raw query results should be cached.'),
      '#options' => $options,
      '#default_value' => $this->options['results_lifespan'],
    ];
    
return $this->isExposed() && !empty($this->options['is_grouped']);
  }

  /** * Provide the basic form which calls through to subforms. * * If overridden, it is best to call through to the parent, * or to at least make sure all of the functions in this form * are called. */
  public function buildOptionsForm(&$form, FormStateInterface $form_state) {
    parent::buildOptionsForm($form$form_state);
    if ($this->canExpose()) {
      $this->showExposeButton($form$form_state);
    }
    if ($this->canBuildGroup()) {
      $this->showBuildGroupButton($form$form_state);
    }
    $form['clear_markup_start'] = [
      '#markup' => '<div class="clearfix">',
    ];
    if ($this->isAGroup()) {
      if ($this->canBuildGroup()) {
        
Home | Imprint | This part of the site doesn't use cookies.