getPreviousFieldLabels example

$options['destination'] = ['default' => TRUE];

    return $options;
  }

  /** * {@inheritdoc} */
  public function buildOptionsForm(&$form, FormStateInterface $form_state) {
    parent::buildOptionsForm($form$form_state);
    // Only show fields that precede this one.     $field_options = $this->getPreviousFieldLabels();
    $form['fields'] = [
      '#type' => 'checkboxes',
      '#title' => $this->t('Fields'),
      '#description' => $this->t('Fields to be included as links.'),
      '#options' => $field_options,
      '#default_value' => $this->options['fields'],
    ];
    $form['destination'] = [
      '#type' => 'checkbox',
      '#title' => $this->t('Include destination'),
      '#description' => $this->t('Include a "destination" parameter in the link to return the user to the original view upon completing the link action.'),
      
'#description' => $this->t("Target of the link, such as _blank, _parent or an iframe's name. This field is rarely used."),
        '#states' => [
          'visible' => [
            ':input[name="options[alter][make_link]"]' => ['checked' => TRUE],
          ],
        ],
      ];

      // Get a list of the available fields and arguments for token replacement.
      // Setup the tokens for fields.       $previous = $this->getPreviousFieldLabels();
      $optgroup_arguments = (string) $this->t('Arguments');
      $optgroup_fields = (string) $this->t('Fields');
      foreach ($previous as $id => $label) {
        $options[$optgroup_fields]["{{ $id }}"] = substr(strrchr($label, ":"), 2);
      }
      // Add the field to the list of options.       $options[$optgroup_fields]["{{ {$this->options['id']} }}"] = substr(strrchr($this->adminLabel(), ":"), 2);

      foreach ($this->view->display_handler->getHandlers('argument') as $arg => $handler) {
        $options[$optgroup_arguments]["{{ arguments.$arg }}"] = $this->t('@argument title', ['@argument' => $handler->adminLabel()]);
        $options[$optgroup_arguments]["{{ raw_arguments.$arg }}"] = $this->t('@argument input', ['@argument' => $handler->adminLabel()]);
      }
Home | Imprint | This part of the site doesn't use cookies.