⚠ In case you've missed it, we have migrated 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 is an archived forum. ⚠

  •     

profile picture

Probleme with callback_insert and Date entry



Daoud Ouassou
  • profile picture
  • Member

Posted 09 July 2016 - 20:22 PM

I'm using Call_back insert to insert a foreign key, But the problem appears when I check the table of entries, The fields with Date entries are empty. Here's My controller .

 public $idt;
     public $insert;
     function __construct()
     {
         parent::__construct();
        $this->load->library('grocery_CRUD');
         // Load url helper
         $this->load->helper('url');

     }
     
     function index(){
         echo "Access granted";
     }
     function table($table , $iditem = null) {
         $gcrud = $this -> grocery_crud;

        $gcrud->set_theme('datatables');

         switch ($table){
             case 'client':
                 $gcrud->set_table($table);
                 $gcrud->set_subject('Clients');
                 $gcrud->columns(array('idClient','NomClient','FormeJuridique','NumTVA','DateEntree','Activite','PaysRegion','Ville',
                     'DateConstitution','TribunalCommerce','SecretariatSocial'));

               $gcrud->callback_column('NomClient',array($this,'_callback_webpage_url'));
                 break;

             case 'declarationtva':
                 $this->idt = $iditem;
                 $this->insert = 'declarationtva';
                 $gcrud->set_table($table);
                 $gcrud->set_subject('Declarations TVA');
                 $gcrud->columns(array('Etat','DateOperationtva','Gestion','Periode','Annee','Observation','idClient'));

                 $gcrud->fields('idDeclarationTVA','Etat','DateOperationtva','Gestion','Periode','Annee','Observation','idClient');
                 $gcrud->field_type('idDeclarationTVA','invisible');
                 $gcrud->field_type('idClient','invisible');


                 $gcrud->where('idClient',$iditem);
                
                   $gcrud->callback_insert(array($this,'iditem_insert_callback'));
                
                  break;

         }

         $out = $gcrud->render();
         $this->load->view('useraccess/userview',array('out'=>$out));

     }

     function iditem_insert_callback($post_array) {

         $post_array['idClient'] = $this->idt;

         return $this->db->insert($this->insert,$post_array);
     }


     
 }