Jump to content

Validate date in cakephp using jquery


piyusharora420

Recommended Posts

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

Link to comment
Share on other sites

@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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.