getFieldLabels example

/** * {@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         // select form.         if (is_string($this->options['grouping'])) {
          $grouping = $this->options['grouping'];
          $this->options['grouping'] = [];
          $this->options['grouping'][0]['field'] = $grouping;
        }
        if (isset($this->options['group_rendered']) && is_string($this->options['group_rendered'])) {
          
$options['url_field'] = ['default' => ''];
    return $options;
  }

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

    $initial_labels = ['' => $this->t('- None -')];
    $view_fields_labels = $this->displayHandler->getFieldLabels();
    $view_fields_labels = array_merge($initial_labels$view_fields_labels);

    $types = [
      'rss' => $this->t('RSS'),
      'link' => $this->t('Link'),
      'include' => $this->t('Include'),
    ];
    $types = array_merge($initial_labels$types);
    $form['type_field'] = [
      '#type' => 'select',
      '#title' => $this->t('Type attribute'),
      
$options['creator_field'] = ['default' => ''];
    $options['date_field'] = ['default' => ''];
    $options['guid_field_options']['contains']['guid_field'] = ['default' => ''];
    $options['guid_field_options']['contains']['guid_field_is_permalink'] = ['default' => TRUE];
    return $options;
  }

  public function buildOptionsForm(&$form, FormStateInterface $form_state) {
    parent::buildOptionsForm($form$form_state);

    $initial_labels = ['' => $this->t('- None -')];
    $view_fields_labels = $this->displayHandler->getFieldLabels();
    $view_fields_labels = array_merge($initial_labels$view_fields_labels);

    $form['title_field'] = [
      '#type' => 'select',
      '#title' => $this->t('Title field'),
      '#description' => $this->t('The field that is going to be used as the RSS item title for each row.'),
      '#options' => $view_fields_labels,
      '#default_value' => $this->options['title_field'],
      '#required' => TRUE,
    ];
    $form['link_field'] = [
      
$options['separator'] = ['default' => ''];
    $options['hide_empty'] = ['default' => FALSE];
    $options['default_field_elements'] = ['default' => TRUE];
    return $options;
  }

  /** * Provide a form for setting options. */
  public function buildOptionsForm(&$form, FormStateInterface $form_state) {
    parent::buildOptionsForm($form$form_state);
    $options = $this->displayHandler->getFieldLabels();

    if (empty($this->options['inline'])) {
      $this->options['inline'] = [];
    }

    $form['default_field_elements'] = [
      '#type' => 'checkbox',
      '#title' => $this->t('Provide default field wrapper elements'),
      '#default_value' => $this->options['default_field_elements'],
      '#description' => $this->t('If not checked, fields that are not configured to customize their HTML elements will get no wrappers at all for their field, label and field + label wrappers. You can use this to quickly reduce the amount of markup the view provides by default, at the cost of making it more difficult to apply CSS.'),
    ];

    

  public function buildOptionsForm(&$form, FormStateInterface $form_state) {
    parent::buildOptionsForm($form$form_state);

    // Get the mapping.     $mapping = $this->defineMapping();

    // Restrict the list of defaults to the mapping, in case they have changed.     $options = array_intersect_key($this->options['mapping']$mapping);

    // Get the labels of the fields added to this display.     $field_labels = $this->displayHandler->getFieldLabels();

    // Provide some default values.     $defaults = [
      '#type' => 'select',
      '#required' => FALSE,
      '#multiple' => FALSE,
    ];

    // For each mapping, add a select element to the form.     foreach ($options as $key => $value) {
      // If the field is optional, add a 'None' value to the top of the options.
$options['search_fields'] = ['default' => []];

    return $options;
  }

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

    $options = $this->displayHandler->getFieldLabels(TRUE);
    $form['search_fields'] = [
      '#type' => 'checkboxes',
      '#title' => $this->t('Search fields'),
      '#options' => $options,
      '#required' => TRUE,
      '#default_value' => $this->options['search_fields'],
      '#description' => $this->t('Select the field(s) that will be searched when using the autocomplete widget.'),
      '#weight' => -3,
    ];
  }

  

      '#fieldset' => 'accessibility_details',
    ];

    // Note: views UI registers this theme handler on our behalf. Your module     // will have to register your theme handlers if you do stuff like this.     $form['#theme'] = 'views_ui_style_plugin_table';

    $columns = $this->sanitizeColumns($this->options['columns']);

    // Create an array of allowed columns from the data we know:     $field_names = $this->displayHandler->getFieldLabels();

    if (isset($this->options['default'])) {
      $default = $this->options['default'];
      if (!isset($columns[$default])) {
        $default = -1;
      }
    }
    else {
      $default = -1;
    }

    
$options['fields'] = ['default' => []];
    $options['destination'] = ['default' => 1];

    return $options;
  }

  /** * {@inheritdoc} */
  public function buildOptionsForm(&$form, FormStateInterface $form_state) {
    $all_fields = $this->view->display_handler->getFieldLabels();
    // Offer to include only those fields that follow this one.     $field_options = array_slice($all_fields, 0, array_search($this->options['id']array_keys($all_fields)));
    $form['fields'] = [
      '#type' => 'checkboxes',
      '#title' => $this->t('Fields'),
      '#description' => $this->t('Fields to be included as contextual links.'),
      '#options' => $field_options,
      '#default_value' => $this->options['fields'],
    ];
    $form['destination'] = [
      '#type' => 'select',
      
'#fieldset' => 'empty_field_behavior',
    ];
  }

  /** * Returns all field labels of fields before this field. * * @return array * An array of field labels keyed by their field IDs. */
  protected function getPreviousFieldLabels() {
    $all_fields = $this->view->display_handler->getFieldLabels();
    $field_options = array_slice($all_fields, 0, array_search($this->options['id']array_keys($all_fields)));
    return $field_options;
  }

  /** * Provide extra data to the administration form. */
  public function adminSummary() {
    return $this->label();
  }

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