In a model: How do I display in the create form, only the fields that I select from the table?
Im my model I have these functions:
function list_items($limit = NULL, $offset = NULL, $col = 'username', $order = 'asc')
{
$this->db->select('id, username, password, email');
$data = parent::list_items($limit, $offset, $col, $order);
return $data;
}
function form_fields($values = array())
{
$fields = parent::form_fields();
$fields['email'] = array('label' => 'Email', 'required' => TRUE);
$fields['password'] = array('type' => 'password', 'label' => 'Password', 'required' => TRUE);
return $fields;
}
When I go to the dashborad to create a teacher, I see a form with all the fields that I have in the users table.
I want to see only the fields that I select from the table, what am I doing wrong?
Comments
$fields['banned']['type'] = 'hidden';
And do that for each field that I don't want to display on the form?
So yes you would need to hide fields individually, although you could create a loop to do the heavy lifting if there are more than you want to show I suppose.