![]() |
Insert form data + date stamp - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Insert form data + date stamp (/showthread.php?tid=34432) |
Insert form data + date stamp - El Forum - 09-29-2010 [eluser]debow[/eluser] I have a form that post data most which is required. I'm wanting to time stamp each insert with just a year stamp. I have the insert working without the year stamp and I'm having issue try to figure out where I specify the date value and insert it with the same insert as the other form data. Controller content is below. Code: function add() Model content is below. I tried adding the info in red below but that's not working. Since date doesn't come from the form how do I get it inserted with the below insert? Quote: function AddAthlete($options = array('date' => 'date("Y")')) Thanks for any help. Insert form data + date stamp - El Forum - 09-29-2010 [eluser]bretticus[/eluser] Since I have no idea what $this->_default() does with your $options array, I'll assume this might work: Code: $options = $this->_default(array(‘athStatus’ => ‘active’), $options); The $options argument in your AddAthlete method (a method is a function in a class) is overwritten by passing $_POST. Thus the default you are showing will never pass in the code you have shown. This is how PHP is supposed to work. You *might* take a look in your _default() method and perhaps put the date code there (since it would seem like that is the place where extra data is attached to your insert ($options) array?) Insert form data + date stamp - El Forum - 09-29-2010 [eluser]debow[/eluser] Since I'm new to both CI and PHP I'm not sure if that's the best way but your suggestion does work and gives me the results I wanted. Going to also look at putting it in the default section. Thank you very much. |