I've used the formhelper in cakephp
echo $this->Form->input('birth_dt', array( 'label' => 'Date of birth'));
I found the day "31" in the month of February... is this a bug? because there is no such thing as february 31
Just like JohnP said, it won't change the dropdown based on the month value. I mean - you can use the FormHelper without any Javascript in your project - so how would it do it anyway?
It would be a rather cool feature though. With the use of jQuery or whatever, you could listen to the month and year dropdowns, and change the options for the day dropdown based of the month/year value. cal_days_in_month(). Not too difficult to do, and I guess it could be included in Cake 2.0 as an additional feature of the FormHelper. As in, if you have the JsHelper on - you can use it.
Well, just because I'm a little bit bored, I wrote this piece of jQuery code:
<script type="text/javascript">
$().ready(function()
{
$('#ModelFieldMonth, #ModelFieldYear').change(function()
{
var day = $('#ModelFieldDay').val();
var month = $('#ModelFieldMonth').val();
var year = $('#ModelFieldYear').val();
var days_in_month = new Array();
days_in_month['01'] = 31; days_in_month['02'] = 28; days_in_month['03'] = 31; days_in_month['04'] = 30; days_in_month['05'] = 31; days_in_month['06'] = 30;
days_in_month['07'] = 31; days_in_month['08'] = 31; days_in_month['09'] = 30; days_in_month['10'] = 31; days_in_month['11'] = 30; days_in_month['12'] = 31;
if (year % 4 == 0) { days_in_month['02'] = 29; } // if leap year
$('#ModelFieldDay').find('option').remove();
var i = 0;
for (i = 1; i <= days_in_month[month]; i++)
{
$('#ModelFieldDay').append('<option value="'+i+'">'+i+'</option>')
}
$('#ModelFieldDay').val(day);
});
});
</script>