public function ExpressionSort::buildOptionsForm in Views Sort Expression 8
Basic options for all sort criteria
Overrides SortPluginBase::buildOptionsForm
File
- src/
Plugin/ views/ sort/ ExpressionSort.php, line 33
Class
- ExpressionSort
- Allows to use any SQL expression
Namespace
Drupal\views_sort_expression\Plugin\views\sortCode
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
$form['expression'] = [
'#type' => 'textarea',
'#title' => t('Expression'),
'#default_value' => $this->options['expression'],
'#description' => t('<b>This is an advanced sort handler.</b> You can use whatever is available on the SQL. If what you need is not on the query, you could add other sort handlers in the end that will make some others to be available. You should probably want to enable "Show the SQL query" on the <a href=":url">settings</a> page.', [
':url' => Url::fromRoute('views_ui.settings_basic')
->toString(),
]),
];
$form['aggregate'] = [
'#type' => 'checkbox',
'#title' => t('Expression has an aggregate function'),
'#default_value' => $this->options['aggregate'],
'#description' => t('This allows you to use an <a href="https://www.w3schools.com/sql/sql_groupby.asp">aggregate function</a> on the expression, instead of relying on the views aggregation plugins which doesn\'t otherwise work nicely with this sort handler.'),
];
}