simple module - customised views
Hi all...
I've set up a simple module but would like to customise it. Can anyone suggest how I can do the following?
1. In my List view, I want to see the ID field
2. In my Form view, I want to see the ID field (as a displayonly)
3. In my List view, I want to display a nice column title - rather than the field name it uses by default. I've done this for my form view...
TIA
__croaker
Comments
function list_items($limit = NULL, $offset = NULL, $col = 'post_date', $order = 'desc') { $this->db->select('id, id AS record_id, job_title, post_date, published', FALSE); $data = parent::list_items($limit, $offset, $col, $order); return $data; }
2. To have your ID field display, try the following in your model's form_field method:
... $fields['id']['__FORM_BUILDER__'] = array('hidden' => ''); ...
3. You can use the db->select(...) as displayed in 1, and use "AS" to give it a different header name.
function form_fields($values = array()) { $fields = parent::form_fields(); $fields['whoID']['__FORM_BUILDER__'] = array('hidden' => ''); $fields['whoID']['hidden'] = ''; $fields['whoID']['label'] = 'ID'; $fields['whoID']['type'] = 'number'; $fields['whoID']['displayonly'] = ''; $fields['whoName']['label'] = 'Name'; return $fields; }
Where my class has public $key_field = 'whoID';
No ID appears in the form
$fields['__FORM_BUILDER__']= array('hidden' => array()); $fields['whoID']= array('type' => '', 'displayonly' => TRUE);