The state of my MY_Model. Inserting data directly from forms with from_form() method

Well… it’s a mess, but it works good for now. And I think it’s evolving, one sign of this being the fact that 20 people stared it on the Github repository (

And now I’ve added a new method to it, namely from_form(), which, by using the form_validation library is taking the data to be inserted from the form.

This means that now you can at any time directly insert values from forms into the tables. First of all make sure you have a fillable or a protected property, because you must make sure no one interferes with your id’s or whatever you use to uniquely identify the rows.

After you’ve done this, you must set the rules. If you use the MY_Model’s form validation, I advise you to write the rules inside your model. Below you can find an example of model:


After setting the model this way, you are ready to go. So, in your controller you can go like this (for the view to work, I am assuming you have loaded the form helper):

Also, the view should look like this:

MY_Model on its Github repository

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">

No spam? * Time limit is exhausted. Please reload CAPTCHA.