simple module - customised views

edited November 2013 in Modules
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

  • edited 12:56AM
    1. The ID field is hidden by default for the List view and is needed for the links used on the far right. You could try something like the following:
    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.
  • edited 12:56AM
    Thanks. 1 & 3 work. I'm having trouble with #2 though:
    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 :(
  • edited 12:56AM
    My mistake on the synax. Try the following instead:
    $fields['__FORM_BUILDER__']= array('hidden' => array()); $fields['whoID']= array('type' => '', 'displayonly' => TRUE);
  • edited 12:56AM
    that did it. thanks.
Sign In or Register to comment.