I have a function where I am allowing a user to enter a business component. Here is the code:
$crud = new grocery_CRUD();
$crud->set_table('business_components');
$crud->set_subject('Business Component');
$crud->set_relation('email','admin','email');
$crud->fields('bus_comp','email');
$crud->change_field_type('email','invisible');
$crud->columns('bus_comp');
$crud->order_by('bus_comp','asc');
// $crud->add_fields(array('bus_comp'));
// $crud->edit_fields(array('bus_comp'));
$crud->callback_before_insert(array($this,'add_email'));
$output = $crud->render();
$this->_configure_output($output);
}catch(Exception $e){
show_error($e->getMessage().' --- '.$e->getTraceAsString());
}
}
function add_email($post_array){
// $Data = base64_decode( urldecode( $this->session->userdata('userid') ) );
$post_array['email']=base64_decode( urldecode( $this->session->userdata('userid') ) );
return $post_array;
}
I am having a user enter a business component but I am also filling in their email address in that same record. The callback is to allow me to set their email address, prior to writing to the database.
My problem is that I added add_fields and edit_fields to make sure that only the business component field displays in the add screen. But when I do this, the email address in the database record is blank. When I uncomment add_fields and edit_fields, the email address gets properly added, but the view shows a place for email address. I have attached a screen shot of the two ways the view appears. I don't want to show an input field for the email address because I am hard coding that in my callback.
Any help on this newby problem is appreciated.