How to Restrict views Date popup to only year/month 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(&amp;$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' =&gt; 'date',
      '#title' =&gt; 'test',
      '#date_date_format' =&gt; 'm/Y',
      '#date_format' =&gt; 'm/Y',
    ];
  }
  return $form;
}
You'll need a external library to do that. Something like jQuery UI Month Picker Plugin and you'll probably will need to use a textfield rather than date.

OR

Use the Month Year module


  This module provides a month year field type.