2amigos / yii2-date-picker-widget

Bootstrap DatePicker Widget for Yii2
https://2amigos.us
Other
130 stars 77 forks source link

Limit date Picker to month and year, by discarding days. #25

Closed remyatgeorge closed 7 years ago

remyatgeorge commented 8 years ago

Im using the date picker widget inside the gridview to filter. But i need a datepicker that shows only month and year. I have tried many options like - 'changeMonth'=>true, 'changeYear'=>true, 'changeDay'=>false, but not working. This is my code:

  <?= GridView::widget([
                                'dataProvider' => $dataProvider,
                                'filterModel' => $searchModel,
                                'columns' => [
                                    'name',
                                    'otp_num',
                                    [
                                       'attribute'=> 'otp_created_date',
                                         'value'=>'otp_created_date',
                                         'format'=>'raw',
                                          'filter'=>DatePicker::widget([
                                                  'model' =>$searchModel,
                                                      'attribute' => 'otp_created_date',
                                                  'clientOptions' => [
                                                      'autoclose' => true,
                                                      'format' => 'yyyy-m-d',
                                                  ]
                                              ]),
                                     ],

                                ],
                                'options' => [
                                    'changeMonth'=>true,
                                    'changeYear'=>true,
                                    'changeDay'=>false,
                                ]
                            ]);
                            ?>
dldamilola commented 8 years ago

Try this options This is bootstrap datepicker, not jQuery.

elamparithi282 commented 5 years ago

echo DatePicker::widget([ 'name' => 'month_only', 'value' => date('M-Y', strtotime('+2 days')), 'options' => ['placeholder' => 'Select issue date ...'], 'pluginOptions' => [ 'autoclose' => true, 'startView'=>'year',
'minViewMode'=>'months', 'format' => 'M-yyyy', 'todayHighlight' => true ] ]);