I have a form where I have a date field, and I would like that the input field is user friendly with a datepicker, and with the looks of Bootstrap. I downloaded the code from the following url:
http://www.eyecon.ro/bootstrap-datepicker/
and this is the code that I have on the form:
- I register the datepicker script
Yii::app()->clientScript->registerScript('dp1', "$('#bd').datepicker({
format: 'dd-mm-yyyy'
});");
- And then I have the following HTML on the form
<div class="control-group ">
<label class="control-label" for="Employee_birthdate">Date of Birth</label>
<div class="controls">
<div class="input-append date" id="bd" data-date="" data-date-format="dd-mm-yyyy">
<input class="span2" name="Employee[birthdate]" id="Employee_birthdate" size="16" type="text" value="" readonly>
<span class="add-on"><i class="icon-calendar"></i></span>
</div>
</div>
</div>
The datepicker works fine, and the the Bootstrap css renders fine, but when on saving the form, the date fields are blank.
I thought I would share this before I go any further as maybe there is another way, better way, of getting date entry on a Yii form. (Could not find it when I searched a bit)
I am using Yii version 1.1.12