⚠ 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

Error loading saving data



Phd2000
  • profile picture
  • Member

Posted 25 March 2021 - 08:58 AM

Hello everyone

 

I'm newbee to coding and I recently discovered Grocery Crud and would like to start a small project.

I have install Grocery Crud Ver 2.01 and Codelgniter  Ver 4.1.1 in local with Wampserver

I want to capitalize the field  « nom_ta_client” in my database but I always have the error “Loading saving data” and if I remove the 2 lines with Callback  all is good no mistake.

Could someone tell me where I made a mistake

Thank you for your help and sorry for my poor English

 

 

 

{
public function prepare($post_array)
{
$post_array['nom_ta_client'] = strtoupper(trim($post_array['nom_ta_client']));        
return $post_array;
}

function get_init_date($post_array)
{
  $post_array['date_creation_ta_client'] = date('d-m-Y');
  $post_array['date_maj_ta_client'] = date('d-m-Y H:i:s');
  return $post_array;
}

 function Client() {
        $crud = new GroceryCrud();

        $crud->setTheme('datatables');

        $crud->setTable('ta_client');

        $crud->columns([
                        'date_creation_ta_client',
                        'date_maj_ta_client',
                        'titre_ta_client',
                        'nom_ta_client',
                        'prenom_ta_client'    
                        ]);

        $crud->setSubject('CLIENT');

        $crud->displayAs('date_creation_ta_client','Date de Création');
        $crud->displayAs('date_maj_ta_client','Date de MAJ');
        $crud->displayAs('titre_ta_client','Titre');
        $crud->displayAs('nom_ta_client','Nom');
        $crud->displayAs('prenom_ta_client','Prénom');

        $crud->requiredFields(['nom_ta_client']);

        $crud->fieldtype('titre_ta_client','enum',array('Mr','Mme','Mlle'));

        $crud->callbackbeforeinsert(array($this,'prepare'));
        $crud->callbackbeforeupdate(array($this,'prepare'));
        
        $crud->setRead();

        $crud->fieldtype('date_creation_ta_client','invisible');
        $crud->fieldtype('date_maj_ta_client','invisible');
        
        $output = $crud->render();

        return $this->_TestOutput($output);
    }

    private function _TestOutput($output = null) {
        return view('Test', (array)$output);
    }
}