Create row in Model through admin panel

edited November 2011 in Modules
Hello everybody.

When I load the model in the panel, all is well. I see a clear listing of all of my entries. However, when I try to either 'CREATE' or 'EDIT' an entry:

CREATE :
Error Number: 1054
Unknown column 'id' in 'field list'
SELECT id, tid FROM (films) ORDER BY `tid` asc
Filename: core/MY_Model.php
Line Number: 685

EDIT : I receive a 404 at /fuel/films/edit/.

I feel like I'm missing something extremely simple and have gone over the tutorial like a mad man. Thus to no avail, I'm stuck. Any help would be much appreciated.

My Model :

class Films_model extends Base_module_model {

public $required = array('uid', 'tid', 'aid', 'title');
public $record_class = 'films';

function __construct()
{
parent::__construct('films');
}

function list_items($limit = NULL, $offset = NULL, $col = '', $order = 'desc')
{
$this->db->select('uid, tid, aid, title', FALSE);
$data = parent::list_items($limit, $offset, $col, $order);
return $data;
}

}

class Film_model extends Base_module_record {

}

__________

My_Fuel_modules :

$config['modules']['films'] = array(
'precedence_col' => 'title',
'default_col' => 'uid',
'instructions' => 'Manage all individual film entries here.',
'archivable' => TRUE,
);

Comments

  • edited 4:58PM
    Does your model have an "id" column. If so, include it in your list_items method like so:
    function list_items($limit = NULL, $offset = NULL, $col = '', $order = 'desc') { $this->db->select('id, uid, tid, aid, title', FALSE); $data = parent::list_items($limit, $offset, $col, $order); return $data; }

    If "uid" is the primary key instead, then you need to define it in the model's key_field property
  • edited November 2011
    No it does not, nor does the model have any mention of it. Not understanding where that query is referred to.

    Do you have any reference to defining the key_field?
    Not sure if I should see it here: http://getfuelcms.com/user_guide/modules/simple
  • edited 4:58PM
    It's under the protected properties found here.
    http://www.getfuelcms.com/user_guide/libraries/my_model

    You can add the following to your model (assuming uid is the primary key):
    class Films_model extends Base_module_model { public $required = array('uid', 'tid', 'aid', 'title'); public $record_class = 'films'; protected $key_field = 'uid'; ...
  • Thanks, I appreciate the help.
Sign In or Register to comment.