buildGroupByForm example

if ($item) {
      $handler = $executable->display_handler->getHandler($type$id);
      if (empty($handler)) {
        $form['markup'] = ['#markup' => $this->t("Error: handler for @table > @field doesn't exist!", ['@table' => $item['table'], '@field' => $item['field']])];
      }
      else {
        $handler->init($executable$executable->display_handler, $item);
        $types = ViewExecutable::getHandlerTypes();

        $form['#title'] = $this->t('Configure aggregation settings for @type %item', ['@type' => $types[$type]['lstitle'], '%item' => $handler->adminLabel()]);

        $handler->buildGroupByForm($form['options']$form_state);
        $form_state->set('handler', $handler);
      }

      $view->getStandardButtons($form$form_state, 'views_ui_config_item_group_form');
    }
    return $form;
  }

  /** * {@inheritdoc} */
  
':input[name="options[group_rows]"]' => ['checked' => TRUE],
        ],
      ],
      '#fieldset' => 'multiple_field_settings',
    ];
  }

  /** * Extend the groupby form with group columns. */
  public function buildGroupByForm(&$form, FormStateInterface $form_state) {
    parent::buildGroupByForm($form$form_state);
    // With "field API" fields, the column target of the grouping function     // and any additional grouping columns must be specified.
    $field_columns = array_keys($this->getFieldDefinition()->getColumns());
    $group_columns = [
      'entity_id' => $this->t('Entity ID'),
    ] + array_map('ucfirst', array_combine($field_columns$field_columns));

    $form['group_column'] = [
      '#type' => 'select',
      '#title' => $this->t('Group column'),
      
Home | Imprint | This part of the site doesn't use cookies.