⚠ 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

Insert value default



n0cturn0
  • profile picture
  • Member

Posted 19 June 2018 - 12:42 PM

how do i a default value to insert into a given field??

 

 

 

$crud = new grocery_CRUD();

$myid = $row->user->id; //this is result the one select

 

$crud->set_table('table');

$crud->function_name('id_user',$myid);

 

<_<

 

 


n0cturn0
  • profile picture
  • Member

Posted 19 June 2018 - 15:31 PM

resolution:

 

public function testeveiculos()
    {
          
            $crud = new grocery_CRUD();
            $crud->set_table('veiculos');
            $crud->columns('marca','modelo','cor','placa');
            $crud->display_as('marca','modelo');
           
            //     ->display_as('customerName','Name')
            //     ->display_as('contactLastName','Last Name');
             $crud->field_type('id_user','invisible');
            $crud->set_subject('NOVO VEICULO');
            //$crud->set_relation('salesRepEmployeeNumber','employees','lastName');
            $crud->callback_before_insert(array($this,'_current_user'));
            $crud->callback_before_update(array($this,'_current_user'));
            $output = $crud->render();

            $this->_example_output($output);


    }


     function _current_user($post_array,$primary_key)
     {
            $user = $this->ion_auth->user()->row();
            $post_array['id_user'] = $user->id;
            return $post_array;
    }

 

 

https://www.grocerycrud.com/documentation/options_functions/callback_before_insert

https://www.grocerycrud.com/documentation/options_functions/callback_before_update

https://www.grocerycrud.com/documentation/options_functions/field_type#invisible-field


dallasgibbs
  • profile picture
  • Member

Posted 27 September 2019 - 07:45 AM

resolution:

 

public function testeveiculos() run 3
    {
          
            $crud = new grocery_CRUD();
            $crud->set_table('veiculos');
            $crud->columns('marca','modelo','cor','placa');
            $crud->display_as('marca','modelo');
           
            //     ->display_as('customerName','Name')
            //     ->display_as('contactLastName','Last Name');
             $crud->field_type('id_user','invisible');
            $crud->set_subject('NOVO VEICULO');
            //$crud->set_relation('salesRepEmployeeNumber','employees','lastName');
            $crud->callback_before_insert(array($this,'_current_user'));
            $crud->callback_before_update(array($this,'_current_user'));
            $output = $crud->render();

            $this->_example_output($output);


    }


     function _current_user($post_array,$primary_key)
     {
            $user = $this->ion_auth->user()->row();
            $post_array['id_user'] = $user->id;
            return $post_array;
    }

 

 

https://www.grocerycrud.com/documentation/options_functions/callback_before_insert

https://www.grocerycrud.com/documentation/options_functions/callback_before_update

https://www.grocerycrud.com/documentation/options_functions/field_type#invisible-field

 

Thanks for the update instruction.


TylerFryer
  • profile picture
  • Member

Posted 28 September 2020 - 13:32 PM

Is it possible to install such a feature on a site that is made on the WordPress platform? And is it possible to display this feature on a separate page?