[ '#title' => $this->t('Title field'), '#description' => $this->t('Choose the field with the custom title.'), '#toggle' => TRUE, '#required' => TRUE, ], 'name_field' => [ '#title' => $this->t('Name field'), '#description' => $this->t('Choose the field with the custom name.'), ], 'numeric_field' => [ '#title' => $this->t('Numeric field'), '#description' => $this->t('Select one or more numeric fields.'), '#multiple' => TRUE, '#toggle' => TRUE, '#filter' => 'filterNumericFields', '#required' => TRUE, ], ]; } /** * Restricts the allowed fields to only numeric fields. * * @param array $fields * An array of field labels, keyed by the field ID. */ protected function filterNumericFields(&$fields) { foreach ($this->view->field as $id => $field) { if (!($field instanceof NumericField)) { unset($fields[$id]); } } } }