piyusharora420 Posted July 18, 2012 Share Posted July 18, 2012 Hi, I have baked one table in cakephp. I have got one date field with three dropdowns for month, day and year respectively.I want to change number of days as per the month and year dropdown in real time. I have worked in same situation in case of core php. But, could not understand how this can be achieved in cakephp. Thanks in advance Quote Link to comment Share on other sites More sharing options...
jazzman1 Posted July 18, 2012 Share Posted July 18, 2012 You want to be something like this, but in cakephp ? Take a look at my script -> http://canada.lesno.net Quote Link to comment Share on other sites More sharing options...
piyusharora420 Posted July 19, 2012 Author Share Posted July 19, 2012 :'( It is showing 28 days for feb 2012 Quote Link to comment Share on other sites More sharing options...
jazzman1 Posted July 19, 2012 Share Posted July 19, 2012 :'( It is showing 28 days for feb 2012 It was just for example. You could be use js date object or modify monthDays array to every leap-year Quote Link to comment Share on other sites More sharing options...
jazzman1 Posted July 20, 2012 Share Posted July 20, 2012 @piyusharora420, you could be use Form-Element-Specific-Methods in cakephp -> http://book.cakephp.org/1.3/en/view/1416/year For example( assuming that the name of the ctp file is called add.ctp) <?php echo $html->script('date.js'); // Include js file?> <?php echo $form->create('ModelName', array('action'=>'add')?> <fieldset> <legend>Add something</legend> <?php echo $form->year('year', 2008, 2016, date('Y'), array('empty' =>'Select year')); echo $form->month('month',null,array('empty'=>'Month')); echo $form->day('day', null, array('empty'=>'Day')) ?> </fieldset> <?php echo $form->end(); ?> After that, you can include a date js file on the top of the page, to modify default values by their id's. Of course, you need to declare "Js" helper method in your controller before use it. http://book.cakephp.org/1.3/en/view/1594/Using-a-specific-Javascript-engine Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.