3

I have a date field in a form widget CActiveForm. The date field is a CJuiDatePicket widget. I would like to put a control so that the user can not enter a date that is in the past.

My code is

<div class="row">
    <?php echo $form->labelEx($model,'date'); ?>
    <?php $this->widget('zii.widgets.jui.CJuiDatePicker',array(
                            'name'=>'Menu[date]',
                            'id'=>'Menu_date',
                        'value'=>Yii::app()->dateFormatter->format("yyyy-MM-dd",strtotime($model->date)),
                            'options'=>array(
                            'showAnim'=>'fold',
                            'dateFormat'=>'yy-mm-dd',
                            'minDate'=>'new Date()'
                            ),
                            'htmlOptions'=>array(
                            'style'=>'height:20px;'
                            ),
                    ));  ?>
    <?php echo $form->error($model,'date'); ?>
</div>

The user no longer has the possibility to select the dates in the pass. Now I want a controller that has an error message if input is a date manually in the pass.

mortiped
  • 869
  • 1
  • 6
  • 28

2 Answers2

1

Set like

 minDate: 0,//0th days from presnt day will be selectable
Dency G B
  • 8,096
  • 9
  • 47
  • 78
  • The user no longer has the possibility to select the dates in the pass. Now I want a controller that has an error message if input is a date manually in the pass. – mortiped Apr 08 '14 at 08:33
  • You can go for two methods here,either show only the calender and hide the text field or write a custom validation rule for the input field. – Dency G B Apr 09 '14 at 03:47
  • Check out this..http://stackoverflow.com/questions/13565483/yii-min-date-validation-rule – Dency G B Apr 09 '14 at 03:52
0

using minDate = '0' user can not enter previous,

Thanks

Ravi D
  • 83
  • 7