#5887: Ability to use custom naming on date fields
------------------------+---------------------------------------------------
    Reporter:  ben      |          Type:  Enhancement
      Status:  new      |      Priority:  Low        
   Milestone:  1.2.x.x  |     Component:  Helpers    
     Version:  RC2      |      Severity:  Minor      
    Keywords:           |   Php_version:  n/a        
Cake_version:           |  
------------------------+---------------------------------------------------
 I was working on an application, and needed the ability to pass a custom
 'name' attribute to a date field, however I found when I did this, the
 Year, Month, and Date fields would all be the same, so the browser would
 only return the Year field instead of the full date.

 I fixed this with this enhancement:

 cake/libs/view/helpers/form.php:

 In function day(), I changed:

                 return $this->select(
                         $fieldName . ".day",
 $this->__generateOptions('day'), $selected, $attributes, $showEmpty
                 );

 To:

                 if (is_array($attributes['name']) &&
 isset($attributes['name']['day'])) {
                         $attributes['name']=$attributes['name']['day'];
                 }

                 return $this->select(
                         $fieldName . ".day",
 $this->__generateOptions('day'), $selected, $attributes, $showEmpty
                 );

 and did a similar modification to the Year, Month, Hour, minute, etc. This
 way, I can give a date field a custom name with code like:

 
$form->input('date_corrected',array('type'=>'date','name'=>array('month'=>'custom_month','day'=>'custom_day','year'=>'custom_year')));


 I don't know if this is an enhancement you'd all want to include in the
 release version, or if there was a better way of doing it, I just felt
 like sharing in the spirit of open source. Feel free to close/delete this
 ticket if it's not correct.

 Thanks,
 Ben

-- 
Ticket URL: <https://trac.cakephp.org/ticket/5887>
CakePHP : The Rapid Development Framework for PHP <https://trac.cakephp.org/>
Cake is a rapid development framework for PHP which uses commonly known design 
patterns like ActiveRecord, Association Data Mapping, Front Controller and MVC. 
Our primary goal is to provide a structured framework that enables PHP users at 
all levels to rapidly develop robust web applications, without any loss to 
flexibility.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"tickets cakephp" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/tickets-cakephp?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to