在 Kartik DatePicker 中隐藏标签部分



我正在尝试从 Yii2 中的 Kartik DatePicker 中删除标头部分。我尝试使用以下代码。

    echo kartikdateDatePicker::widget([
        'model' => $employmentMod,
        'form' => $form,
        'attribute' => "[$index]emp_date_from",
        'options' => [
            'placeholder' => 'Select date ...', 
            'template' => '{widget}{error}',
            'class' => 'detaildatepicker', 
            ],
        'pluginOptions' => [                
            'todayHighlight' => true,
            'autoclose' => true,
            'format' => 'yyyy-mm-dd',
        ]
    ]);

它仍然不起作用。我传递了$form,因为我需要显示验证错误。有人可以告诉我如何在这里使用模板吗?

为此

小部件添加type选项以指定组件的标记:

echo kartikdateDatePicker::widget([
        'model' => $employmentMod,
        'form' => $form,
        'attribute' => "[$index]emp_date_from",
        'options' => [
            'placeholder' => 'Select date ...', 
            'template' => '{widget}{error}',
            'class' => 'detaildatepicker', 
            ],
        'type'=> kartikdateDatePicker::TYPE_INPUT,
        'pluginOptions' => [                
            'todayHighlight' => true,
            'autoclose' => true,
            'format' => 'yyyy-mm-dd',
        ]
    ]);

这可以使用正常的表单行为来完成。

看看这个。

               $form->field($model, 'start_date')
                    ->label(false)
                    ->widget('kartikdateDatePicker', [
                        'pluginOptions' => [
                            'format'         => 'yyyy-mm-dd',
                            'todayHighlight' => true,
                            'clearButton'    => false,
                        ]
                    ]);

最新更新