public function CronExpireDate::buildOptionsForm in http:BL 8
Default options form that provides the label widget that all fields should have.
Overrides Date::buildOptionsForm
File
- src/
Plugin/ views/ field/ CronExpireDate.php, line 22
Class
- CronExpireDate
- Field handler to display the newer of last comment / node updated.
Namespace
Drupal\httpbl\Plugin\views\fieldCode
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
$date_formats = array();
foreach ($this->dateFormatStorage
->loadMultiple() as $machine_name => $value) {
$date_formats[$machine_name] = $this
->t('@name format: @date', array(
'@name' => $value
->label(),
'@date' => $this->dateFormatter
->format(\Drupal::time()
->getRequestTime(), $machine_name),
));
}
$form['date_format'] = array(
'#type' => 'select',
'#title' => $this
->t('Date format'),
'#options' => $date_formats + array(
// Added option.
'cron time expire' => $this
->t('Cron expire date countdown (0 = "(next cron)")'),
),
'#default_value' => isset($this->options['date_format']) ? $this->options['date_format'] : 'small',
);
// Setup #states for 'cron time expire' form element.
foreach (array(
'cron time expire',
) as $custom_date_possible) {
$form['custom_date_format']['#states']['visible'][] = array(
':input[name="options[date_format]"]' => array(
'value' => $custom_date_possible,
),
);
}
foreach (array_merge(array(
'custom',
), array_keys($date_formats)) as $timezone_date_formats) {
$form['timezone']['#states']['visible'][] = array(
':input[name="options[date_format]"]' => array(
'value' => $timezone_date_formats,
),
);
}
}