⚠ 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

callback edit/add field



xxaxxo

xxaxxo
  • profile picture
  • Member

Posted 07 November 2012 - 13:06 PM

Is there an easy way I can add a variable to be passed to my callback function

exaple:

$crud->callback_edit_field($field, array($this, '_function_callback'), $myvar);

then in my _function_callback just to retriev myvar

victor

victor
  • profile picture
  • Member

Posted 07 November 2012 - 14:33 PM

Hi! You can use a sessions as solution.

xxaxxo

xxaxxo
  • profile picture
  • Member

Posted 07 November 2012 - 15:07 PM

sessions are unusable if you have multiple relation_n_n fields you like to edit before / add_before insert
there is a third parameter which is an object and has the info for the relation_n_n (which was what i needed in my case)

fabgonber

fabgonber
  • profile picture
  • Member

Posted 08 November 2012 - 11:51 AM

my solution for the same:

in the grocery_crud controller class:

function facturas()
{
$crud = new grocery_CRUD();
$crud->set_language("spanish");
$crud->set_table('factura');
$crud->columns('factura_id','clientefacturado_id','matricula_id',,'factura');
$crud->callback_column('factura',array($this,'goMenuFacturas'));
$output = $crud->render();
}


function goMenuFacturas($value, $row)
{
$atts = array('target' => 'dentrodematricula');
$tmp = anchor_popup("post2get/veralgo/".$row->matricula_id,"<small>ver algo</small>",$atts);
return $tmp;
}

next in another controller (post2get) i pass the data to a session :


function veralgo($matricula_id)
{
$this->session->set_userdata('matricula_id',$matricula_id);
redirect('facturas_crud/another');
}


returning to the grocery controller:



function another()
{
$matricula_id = $this->session->userdata('matricula_id'); // HERE
$crud = new grocery_CRUD();
$crud->set_language("spanish");
$crud->set_table('xyz');

...

$output = $crud->render();
}

Angga Pino

Angga Pino
  • profile picture
  • Member

Posted 15 November 2013 - 10:55 AM

xxaxxo.. Yes you right. "sessions are unusable if you have multiple relation_n_n"

did you solve it?

 

 


victor

victor
  • profile picture
  • Member

Posted 15 November 2013 - 13:45 PM

con you explain what you want in more words?

Angga Pino

Angga Pino
  • profile picture
  • Member

Posted 17 November 2013 - 18:59 PM

move my question

/topic/2427-callback-insertcallback-update-not-work-with-set-relation-n-n/#entry10607