first of all, thanks for making gCRUD, it seems like an excellent project.
Is it at all possible to pass variables from one table into the add form for another?
As an example I have a table of sales leads. once I take care of the leads I want to click a button to convert them to a jobs table.
This function might give you a better idea of what I am trying to accomplish:
function leads()
{
/* This is only for the autocompletion */
$crud = new grocery_CRUD();
$crud->set_theme('datatables');
$crud->set_table('leads');
$crud->set_subject('Label Leads');
$crud->add_action('Add Job', '', '','ui-icon-image',array($this,'add_job'));
$output = $crud->render();
$this->_example_output($output);
}
function add_job($primary_key , $row)
{
return site_url('http://domain.com/index.php/crm/jobs/add/').'?company='.$row->company;
}
thank you!
pass variable into add form?
Started by jezeus, 16 March 2012 - 03:02 AM
- Single Page
Posted 16 March 2012 - 03:02 AM
Posted 16 March 2012 - 06:59 AM
As I understood, you can simply do it with the callback_edit_field ( http://www.grocerycrud.com/documentation/options_functions/callback_edit_field ). The second parameter is the $primary key so for now you will just have a quick query for example:
as for the field name you can have a fake field for example:
so you will just have the line:
and everything will work OK.
function edit_field_callback_1($value, $primary_key)
{
$this->db->where('id',$primary_key);
$lead = $this->db->get('leads')->row();
return "<a href='".site_url('http://domain.com/index.php/crm/jobs/add/').'?company='.$lead->company."'>add company</a>";
}
as for the field name you can have a fake field for example:
$crud->edit_fields('fristname',...,'add_company',....);
so you will just have the line:
$crud->callback_edit_field('add_company',array($this,edit_field_callback_1));
and everything will work OK.