dawood rizwan
dawood rizwan

Reputation: 193

how to display datepicker upto current date and should not display future date in yii framework

i am developing web application by using yii framework, i am displaying datepicker for filing date of birth, i have two dropdown also in my datepicker like month and year now everything is working fine. this is my datepicker with month and year dropdown code

<?php
    $this->widget('zii.widgets.jui.CJuiDatePicker', array(
        'attribute' => 'birth',
        'name' => 'birth',
        'value'=>$model->birth,
        'model' => $model,
        'options'=>array(
        'showAnim'=>'fold',
        'dateFormat'=>'yy-m-d',
        'changeYear' => true,           // can change year
        'changeMonth' => true,          // can change month
        'yearRange' => '1950:2099',     // range of year
        'minDate' => '1950-01-01',      // minimum date
        'maxDate' => '2099-12-31',
        'showButtonPanel' => false, 
       ),
        'htmlOptions' => array(
        'size' => '10',         // textField size
        'maxlength' => '10',    // textField maxlength
    ),
  ));
?>

enter image description here

my requirement:- actually i am using datepicker for date of birth so, i need to display calender upto current date. for example today date is 5/4/2015 and my calender also should show upto 5/4/2015 which means it should not display future date. is it possible?. if it is possible how can we do it. could you please help me

Upvotes: 0

Views: 1343

Answers (1)

topher
topher

Reputation: 14860

Just set

'yearRange' => '1950:'.date('Y'),
'maxDate' => date('Y-m-d')

Upvotes: 2

Related Questions