public function ArgOrderSort::buildOptionsForm in Views Argument Order Sort 8
Same name and namespace in other branches
- 2.x src/Plugin/views/sort/ArgOrderSort.php \Drupal\views_arg_order_sort\Plugin\views\sort\ArgOrderSort::buildOptionsForm()
Basic options for all sort criteria
Overrides SortPluginBase::buildOptionsForm
File
- src/
Plugin/ views/ sort/ ArgOrderSort.php, line 33
Class
- ArgOrderSort
- Handle a random sort.
Namespace
Drupal\views_arg_order_sort\Plugin\views\sortCode
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
$options = [];
$base_tables = Views::viewsData()
->fetchBaseTables();
$table_data = Views::viewsData()
->getAll();
foreach ($base_tables as $table => $values) {
$data = $table_data[$table];
$group = (string) render($data['table']['group']);
foreach ($data as $field => $f) {
if (isset($f['entity field'])) {
$options[$group][$table . '::' . $field] = render($f['title']);
}
}
}
$form['argument_number'] = [
'#title' => $this
->t('Argument'),
'#type' => 'select',
'#options' => [
1,
2,
3,
4,
5,
6,
7,
8,
9,
],
'#default_value' => $this->options['argument_number'],
];
$form['null_below'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Non arguments at End'),
'#description' => $this
->t('Place items not in the argument at the end.'),
'#default_value' => $this->options['null_below'],
'#options' => [
0,
'Null values below',
],
];
$form['inherit_type'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Inherit type of Field from Argument'),
'#description' => $this
->t('If the argument is the NULL argument or you want to choose a different type for linking the uncheck, otherwise it is safe to leave it checked.'),
'#default_value' => $this->options['inherit_type'],
'#options' => [
0,
'Inherit type of Field from Argument',
],
'#ajax' => [
'callback' => 'views_boxes_arg_order_type_callback',
'wrapper' => 'arg-order-type',
'method' => 'replace',
'effect' => 'fade',
],
];
$form['field_type'] = [
'#title' => $this
->t('Type of Argument Field'),
'#type' => 'select',
'#options' => $options,
'#default_value' => $this->options['field_type'],
];
}