if (!
$form_state->
get('exposed'
)) { $form['value'
]['type'
] =
[ '#type' => 'radios',
'#title' =>
$this->
t('Value type'
),
'#options' =>
[ 'date' =>
$this->
t('A date in any machine readable format. CCYY-MM-DD HH:MM:SS is preferred.'
),
'offset' =>
$this->
t('An offset from the current time such as "@example1" or "@example2"',
['@example1' => '+1 day', '@example2' => '-2 hours -30 minutes'
]),
],
'#default_value' => !
empty($this->value
['type'
]) ?
$this->value
['type'
] : 'date',
];
} parent::
valueForm($form,
$form_state);
} public function validateOptionsForm(&
$form, FormStateInterface
$form_state) { parent::
validateOptionsForm($form,
$form_state);
if (!
empty($this->options
['exposed'
]) &&
$form_state->
isValueEmpty(['options', 'expose', 'required'
])) { // Who cares what the value is if it's exposed and non-required.
return;
} $this->
validateValidTime($form['value'
],
$form_state,
$form_state->
getValue(['options', 'operator'
]),
$form_state->
getValue(['options', 'value'
]));
}