簡體   English   中英

CJuiDatePicker,需要YII日期選擇器

[英]CJuiDatePicker, YII Date Picker required

有沒有辦法將CJuiDatePicker驗證為必填字段?

<?php     
        $this->widget('zii.widgets.jui.CJuiDatePicker',array(
                                    'model'=>$model,
                                    'attribute'=>'bdate',
                                    'options'=>array( 
                                                'showAnim'=>'fadeIn', 
                                                'dateFormat'=>'mm/dd/yy',
                                                'changeMonth'=>true,
                                                'changeYear'=>true,
                                                'minDate'=>'01/01/1900',
                                                'yearRange' => '-200:+0',
                                                'maxDate'=>'0',
                                                ),
                                    'htmlOptions'=>array('readonly' => true, 'class' => "form-control", 'required'=> 'true', 'value'=>isset($_SESSION["bdate"])?$_SESSION["bdate"]:'')
                            ));
                        ?>

謝謝!

只需將“ bdate”聲明為模型中的必需屬性即可:

public function rules()
    {
        return array(
            ...
            array('bdate', 'required'),
            ...
        );
    }

有問題嗎?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM