⚠ In case you've missed it we are migrating to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This forum is read-only and soon will be archived. ⚠


Member Since 26 Mar 2014
Offline Last Active Apr 20 2015 01:01 AM

#10960 How do I add a non-editable field that contains the field of current time??

Posted jonathanw on 27 March 2014 - 12:30 PM

I have 2 DATETIME columns in my table, named "created" and "modified".

As I want the value to be generated automaticly, and as well as modified updating every time the post is updated, while created only added once, I did like this:

public function _callback_fix_created($p) {
        $date_time = date("Y-m-d H:i:s");
        $p['created'] = $date_time;
        $p['modified'] = $date_time;
        return $p;
    public function _callback_fix_modified($p) {
        $p['modified'] = date("Y-m-d H:i:s");
        return $p;

    public function index() {


You could set another field type of course, I have chosen to have my fields completely hidden in the add and edit form.