public function TableSorterSettings::buildForm in Tablesorter 8
Same name and namespace in other branches
- 3.0.x src/Form/TableSorterSettings.php \Drupal\tablesorter\Form\TableSorterSettings::buildForm()
Form constructor.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
array The form structure.
Overrides ConfigFormBase::buildForm
File
- src/
Form/ TableSorterSettings.php, line 34
Class
- TableSorterSettings
- Table sorter settings form.
Namespace
Drupal\tablesorter\FormCode
public function buildForm(array $form, FormStateInterface $form_state, Request $request = NULL) {
$config = \Drupal::config('tablesorter.settings');
$form['tablesorter_theme'] = [
'#type' => 'select',
'#title' => $this
->t('Select Theme'),
'#options' => [
'system' => $this
->t("System's Default"),
'blue' => $this
->t('Blue'),
'green' => $this
->t('Green'),
],
'#default_value' => $config
->get('tablesorter_theme'),
'#description' => $this
->t('Set the theme for header.'),
'#required' => TRUE,
];
$form['tablesorter_zebra'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Maintain zebra striping on tables'),
'#description' => $this
->t("Re-stripe table rows with 'odd', 'even' classes after sorting"),
'#default_value' => $config
->get('tablesorter_zebra'),
];
$form['tablesorter_zebra_odd_class'] = [
'#type' => 'textfield',
'#title' => $this
->t('Odd row class'),
'#description' => $this
->t("Select the class added to odd rows. Defaults to 'odd'"),
'#default_value' => $config
->get('tablesorter_zebra_odd_class'),
];
$form['tablesorter_zebra_even_class'] = [
'#type' => 'textfield',
'#title' => $this
->t('Even row class'),
'#description' => $this
->t("Select the class added to even rows. Defaults to 'even'"),
'#default_value' => $config
->get('tablesorter_zebra_even_class'),
];
return parent::buildForm($form, $form_state);
}