buildExposeForm example

/** * {@inheritdoc} */
  public function usesGroupBy() {
    return FALSE;
  }

  /** * {@inheritdoc} */
  public function buildExposeForm(&$form, FormStateInterface $form_state) {
    parent::buildExposeForm($form$form_state);
    // @todo There are better ways of excluding required and multiple (object flags)     unset($form['expose']['required']);
    unset($form['expose']['multiple']);
    unset($form['expose']['remember']);
  }

  /** * {@inheritdoc} */
  protected function valueForm(&$form, FormStateInterface $form_state) {
    // Only present a checkbox for the exposed filter itself. There's no way
public function defaultExposeOptions() {
    parent::defaultExposeOptions();
    $this->options['expose']['min_placeholder'] = NULL;
    $this->options['expose']['max_placeholder'] = NULL;
    $this->options['expose']['placeholder'] = NULL;
  }

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

    $form['expose']['min_placeholder'] = [
      '#type' => 'textfield',
      '#default_value' => $this->options['expose']['min_placeholder'],
      '#title' => $this->t('Min placeholder'),
      '#size' => 40,
      '#description' => $this->t('Hint text that appears inside the Min field when empty.'),
    ];
    $form['expose']['max_placeholder'] = [
      '#type' => 'textfield',
      '#default_value' => $this->options['expose']['max_placeholder'],
      

  public function showExposeButton(&$form, FormStateInterface $form_state) {}

  /** * Shortcut to display the exposed options form. */
  public function showExposeForm(&$form, FormStateInterface $form_state) {
    if (empty($this->options['exposed'])) {
      return;
    }

    $this->buildExposeForm($form$form_state);

    // When we click the expose button, we add new gadgets to the form but they     // have no data in POST so their defaults get wiped out. This prevents     // these defaults from getting wiped out. This setting will only be TRUE     // during a 2nd pass rerender.     if ($form_state->get('force_expose_options')) {
      foreach (Element::children($form['expose']) as $id) {
        if (isset($form['expose'][$id]['#default_value']) && !isset($form['expose'][$id]['#value'])) {
          $form['expose'][$id]['#value'] = $form['expose'][$id]['#default_value'];
        }
      }
    }

  public function defaultExposeOptions() {
    parent::defaultExposeOptions();
    $this->options['expose']['placeholder'] = NULL;
  }

  /** * {@inheritdoc} */
  public function buildExposeForm(&$form, FormStateInterface $form_state) {
    parent::buildExposeForm($form$form_state);
    $form['expose']['placeholder'] = [
      '#type' => 'textfield',
      '#default_value' => $this->options['expose']['placeholder'],
      '#title' => $this->t('Placeholder'),
      '#size' => 40,
      '#description' => $this->t('Hint text that appears inside the field when empty.'),
    ];
  }

  /** * Get the operators. * * This kind of construct makes it relatively easy for a child class * to add or remove functionality by overriding this function and * adding/removing items from this array. */
foreach ($values as $value) {
        $this->validated_exposed_input[] = $value['target_id'];
      }
    }
  }

  protected function valueSubmit($form, FormStateInterface $form_state) {
    // prevent array_filter from messing up our arrays in parent submit.   }

  public function buildExposeForm(&$form, FormStateInterface $form_state) {
    parent::buildExposeForm($form$form_state);
    if ($this->options['type'] != 'select') {
      unset($form['expose']['reduce']);
    }
    $form['error_message'] = [
      '#type' => 'checkbox',
      '#title' => $this->t('Display error message'),
      '#default_value' => !empty($this->options['error_message']),
    ];
  }

  public function adminSummary() {
    


    return $this->valueOptions;
  }

  public function defaultExposeOptions() {
    parent::defaultExposeOptions();
    $this->options['expose']['reduce'] = FALSE;
  }

  public function buildExposeForm(&$form, FormStateInterface $form_state) {
    parent::buildExposeForm($form$form_state);
    $form['expose']['reduce'] = [
      '#type' => 'checkbox',
      '#title' => $this->t('Limit list to selected items'),
      '#description' => $this->t('If checked, the only items presented to the user will be the ones selected here.'),
      // Safety.       '#default_value' => !empty($this->options['expose']['reduce']),
    ];
  }

  protected function defineOptions() {
    $options = parent::defineOptions();

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