$this->load->library('Grocery_CRUD'); try { $crud = new grocery_CRUD(); $crud->set_theme('flexigrid'); $crud->set_table('vp_contacts') ->where('venue_id',$this->session->userdata('venue_id')) ->set_subject('Contacts') ->columns('contact_updated','contact_fname','contact_lname','contact_email') ->display_as('contact_fname','First Name') ->display_as('contact_lname','Last Name') ->display_as('contact_email','Email'); $crud->fields('contact_updated','contact_fname','contact_lname','contact_email'); //$crud->change_field_type('contact_updated','invisible'); $crud->callback_before_insert(array($this,'set_time')); $crud->callback_before_update(array($this,'set_time')); $crud->required_fields('contact_fname','contact_lname'); function set_time($post_array){ $post_array['contact_updated'] = date('Y-m-d H:i:s'); return $this->db->insert('vp_contacts',$post_array); } $crud->unset_jquery(); $output = $crud->render(); } catch(Exception $e) { show_error($e->getMessage().' --- '.$e->getTraceAsString()); }
I'm running to an issue where $crud->callback_before_update / insert is not setting datetime and updating the contact records. Interesting enough all other fields allowed to be edited are working fine just 'contact_updated' remains default through attempts to edit and or insert new. Any advise please?