首页 > 解决方案 > 无法为 DateRangePicker::widget 设置占位符

问题描述

我的 yii2 应用程序中有以下小部件

 <?= DateRangePicker::widget([
                'model'=>$model,
                'attribute' => 'fact_close_date_range',
                'options'=>[
                    'placeholder'=>'Фактическая дата закрытия займа',
                    'class'=> 'ui input',
                    'id'=> 'fact_close_date_range'
                ],
                'useWithAddon'=>false,
                'convertFormat'=>true,
                'presetDropdown'=>false,
                'hideInput'=>false,
                'pluginOptions'=>[
                    'opens'  => 'right',
                    'locale'=>[
                        'format' => 'Y-m-d'
                    ],
                ],
            ]); 
            ?>

但是在初始加载时,我得到的是为今天设置两个日期的输入。例如 17.03.2021 - 17.03.2021,应该是我的占位符Фактическая дата закрытия займа。kartik 的文档没有描述这样的事情

标签: phpdatepickeryii2

解决方案


尝试这个 :

<?= DateRangePicker::widget([
                                   'name'=>'date_range_2',
                                    'presetDropdown'=>true,
                                    'convertFormat'=>true,
                                    'value' => $model->date_range,
                                    // 'includeMonthsFilter'=>true,
                                    'pluginOptions'=> ['locale' => ['format' => 'Y-m-d']],
                                    'options' => ['id'=> 'tgl-search', 'class' => 'invoice-search','placeholder' => 'Select range...']
                                ]);


推荐阅读