CRUD for a subset of users
- Single Page
Posted 28 January 2013 - 14:33 PM
One thing I am having problems with is how to go about the following.
I need to maintain a 'user list' for many offers, so have an 'Offer Table' and a linked 'User Table'. Ideally I want to display a list of Offers for the Admin to select from and then set up the CRUD to LIST/ADD/CHANGE/DELETE the User records just for that Offer.
I have a piece working which displays the list of Offers and then the filtered list of records for the selected Offer which is based on using the where clause to filter the record set using the supplied OfferID
$state = $crud->getState();
if($state=='list' && $this->uri->segment(5)==""){// need to display a form to get the offer
$this->load->model('offers_model');
$data['offers']=$this->offers_model->get_all_offers_for_select();
$this->load->view('admin/selectoffer',$data);
return;
}
if($state=='list' && $this->uri->segment(5)!=""){
$offer_id = $this->uri->segment(5);
}
$crud->set_table('user_list');
if($offer_id != ""){
$crud->where('offer_id',$offer_id);
$crud->field_type('offer_id','hidden',$offer_id);
}
$crud->columns('email','e164');
$crud->add_fields('offer_id','email','e164');
$crud->edit_fields('email','e164');
$crud->order_by('offer_id','email');
//$crud->display_as('offer_id','Offer');
$crud->display_as('email','Email Address');
$crud->display_as('e164','e.164 Number');
$crud->set_rules('email','Email Address','required');
$crud->set_rules('e164','e.164 Number','required');
//$crud->set_rules('offer_id','Offer','required');
$crud->set_relation('offer_id','offer','name',array('deleted' => 0));
log_message('debug',"***** OfferID :=" . $offer_id );
$output = $crud->render();
$this->_display_output($output);
This works OK for List, Edit and Delete, but somehow I need to get the OfferID into the ADD mode.
Any recommended ways to do this?
Thanks Mike
Posted 30 January 2013 - 10:16 AM
http://www.grocerycrud.com/documentation/options_functions/callback_add_field
Posted 31 January 2013 - 10:34 AM
Posted 31 January 2013 - 10:37 AM