Creating Simple Modules, Tutorial
Hi,
I have went through the simple modules tutorial and I have found few minor typo mistakes and I have also one question regarding the required form fields.
1) Create the Articles Model
class Articles_model extends Base_module_model {}
class Articles_model extends Base_module_record {} // => Should be class Article_model
2) The Tree Method
function tree()
{ ...
$categories_to_articles = $CI->categories_to_articles_model->find_all('', 'name asc'); => I had to specify second parameter - categories.name otherwise I got ambiguity error.
...
}
3) Adding an After Save Hook
Everything works fine, when one selects a category for an article. If there is no category selected I get db error after hitting "save" button. It could be probably good to make category selection required, but I did not find an easy way how. Here comes my question - Can it be somehow done via public $required array?
Comments
$this->get_validation()->add_rule('categories', 'required, 'This field is required', $_POST['categories']);