Issue
I have a datetime field in my database called start_time
that I would like updated with the current datetime when a user performs a specific action. I would also like this field to be hidden in the edit view.
I have tried a number of combinations in the form in my edit view as well as reading through some other similar questions on this but its not working (or i am not fully understanding other posts).
Just some samples of combinations I have tried include:
echo $this->Form->hidden('start_time', ['value' => date('Y-m-d H:i:s')]);
echo $this->Form->input('start_time', ['type'=>'hidden','value' => date('Y-m-d H:i:s')]);
If I leave the baked form view of echo $this->Form->input('start_time')
I see that individual [year], [month], [day] select options are created in the HTML, just wanting to understand if I need to add 6 hidden form options to cover start_time[year], start_time[month], etc... to cover all the Y-m-d H:i:s fields of a MYSQL datetime format...
Any help is appreciated. Thanks! mk
Solution
Solution for my issue was actually in the answer found here. Basically adding the beforeMarshal call into my [mymodel]Table.php and once I did this correctly the valid datetime format was added into my DB field.
Apologies for somewhat duplicate question.
Answered By - mk97
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.