⚠ 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

Action Primary_key is always the Last ID of the list.



Luan
  • profile picture
  • Member

Posted 25 April 2012 - 00:07 AM

Im trying to send the ID (causa_id, primary key) to a different view using action, and there fill a hidden field.
I dont want to use the URI to prevent users from changing the info. I tryed the way bellow and it always returns the last item of the list (if ordered by id, the last id. If ordered by name, the id of the last name, etc)

I've tryed also $row->causa_id, or selecting the name, (select causa_nome where causa_id $primary_key), but its always the same.

Any help wold be apreciated.

function causas()
{
$this->ag_auth->restrict('admin', TRUE);
$crud = new grocery_CRUD();
$crud->set_table('causas')->order_by('causa_nome', 'ASC');
$crud->set_subject('Causas');
$crud->unset_operations();
$crud->columns('causa_nome','a_id','email','cat_slug_id','telefone1');
///////////Relações//////////
$crud->set_relation('cat_slug_id','categorias','cat_nome');

$crud->callback_column('a_id',array($this,'callback_column_1'));

$crud->required_fields('causa_nome');
$crud->add_action('Login', '', 'cms/registro','ui-icon-plus',array($this,'registro'));
$crud->add_action('Alterar', '', 'cms/alterar_causa','ui-icon-pencil');

$output = $crud->render();
$data['titulo'] = humanize($this->uri->segment(2));
$output = array_merge($data,(array)$output);
$this->_output_data($output);
}

function registro($primary_key, $row)
{
$this->session->set_flashdata('causa', $primary_key);
return site_url('register');
}