public function YandexMetricsReportsFilterForm::buildForm in Yandex.Metrics 8.2
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 FormInterface::buildForm
File
- yandex_metrics_reports/
src/ Form/ YandexMetricsReportsFilterForm.php, line 28 - Contains \Drupal\yandex_metrics_reports\Form\YandexMetricsReportsFilterForm.
Class
- YandexMetricsReportsFilterForm
- Provides quick filter form for reports page.
Namespace
Drupal\yandex_metrics_reports\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
$current_filter = arg(3) ? arg(3) : 'week';
$options = array(
'day' => t('Today'),
'yesterday' => t('Yesterday'),
'week' => t('Week'),
'month' => t('Month'),
);
$form['filter'] = array(
'#type' => 'select',
'#title' => t('Quick filter'),
'#default_value' => $current_filter,
'#options' => $options,
'#attributes' => array(
'onchange' => 'this.form.submit();',
),
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Submit'),
'#attributes' => array(
'style' => 'display:none;',
),
);
return $form;
}