Quantcast
Channel: Yii Framework Forum
Viewing all articles
Browse latest Browse all 18717

Cactivefrom And Date Fields

$
0
0
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:
1. I register the datepicker script

Yii::app()->clientScript->registerScript('dp1', "$('#bd').datepicker({
	format: 'dd-mm-yyyy'
});");


2. 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

Viewing all articles
Browse latest Browse all 18717

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>