I want to have views exposed filter on node created
field with popup.
I've installed date_popup, the popup appears but I'm looking for a way to restrict it to only year and month.
I tried the following solutions but no success.
function HOOK_form_alter(&$form, FormStateInterface $form_state, $form_id) {
if( $form['#id'] == 'views-exposed-form-news-page-1') {
$form['created']['#date_format'] = 'm-Y';
$form['created']['#date_date_format'] = 'm-Y';
$form['created']['value']['#date_format'] = 'm-Y';
$form['created']['value']['#date_date_format'] = 'm-Y';
$form['date_needed'] = [
'#type' => 'date',
'#title' => 'test',
'#date_date_format' => 'm/Y',
'#date_format' => 'm/Y',
];
}
return $form;
}
<input type="date">
then you will always get the native date picker. You need to do<input type="text">
if you want to override this behavior. But, I am not familiar with the date_popup to know how to integrate it with Form API.