It looks like you're new here. If you want to get involved, click one of these buttons!
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
require_once(FUEL_PATH.'models/base_module_model.php');
class Articles_model extends Base_module_model {
public $foreign_keys = array('author_id' => 'authors_model');
public $parsed_fields = array('content', 'content_formatted');
function __construct()
{
parent::__construct('articles'); // table name
}
function list_items($limit = NULL, $offset = NULL, $col = 'name', $order = 'asc')
{
$this->db->join('authors', 'authors.id = articles.author_id', 'left');
$this->db->select('articles.id, authors.name AS author, title, SUBSTRING(content, 1, 50) AS content, date_added, articles.published', FALSE);
$data = parent::list_items($limit, $offset, $col, $order);
return $data;
}
function form_fields($values = array())
{
$fields = parent::form_fields($values);
// ******************* ADD CUSOM FORM STUFF HERE *******************
return $fields;
}
}
class Article_model extends Data_record {
}
Comments
And you are viewing the form under the fuel/articles? Also, does the database table it's referencing have that field in it and do the other fields match up to what is represented in the database table.
If you are just starting out, I'd recommend trying out the 1.0 beta which contains a lot of new features as well as the ability to create model relationship like has_many and belongs to without the need for relationship tables:
https://github.com/daylightstudio/FUEL-CMS/tree/1.0
I am viewing it under fuel/articles/create, it seems to be displaying all the fields that are in the database except 'id' and 'date_added'. This is my database:
And this is the form it's showing:
Still with the same model I posted above. I also added another field in the db called 'test', the model remained unchanged and the form still displayed it
function form_fields($values = array()) { $fields = parent::form_fields($values); $fields['title']['type'] = 'textarea'; return $fields; }
$this->db->select('articles.id, authors.name AS author, title, SUBSTRING(content, 1, 50) AS content, date_added, articles.published', FALSE);
I thought it would change what was selected from the database, but it doesn't do anything. This is the tutorial screenshot:
http://www.getfuelcms.com/fuel/modules/user_guide/assets/images/examples/articles_form.png
And you can see it differs from my screenshot because it doesn't have the 'Permalink' field. What is making that not show if it isn't the select?
Thank you for being patient, hopefully that explains a bit better what I'm confused on.
function form_fields($values = array()) { $fields = parent::form_fields($values); $fields['author_id']['options'] = array('1' => 'Me'); // this just needs to be an associative array value return $fields; }
Or you could try overwriting the model's list_options method, which is inherited from the MY_Model class.
Thank you for the help =D