Welcome Guest, Not a member yet? Register   Sign In
Populate model from a form submission
#1

[eluser]juddmuir[/eluser]
Hi,

This is a very common requirement:

- display form for user input
- receive form data
- update database

I was just wondering if there was any existing/standard code that receives a form and then populates a given model's variables?

Something like:
$userdetails = &new;Users_model();
$userdetails->readForm();
$userdetails->persist();

Thanks in advance for any replies :-)
#2

[eluser]GSV Sleeper Service[/eluser]
the Doctrine ORM can do something similar, some example code.
Code:
$address = new Address;
$address->merge($_POST);
$address->save();
'Address' is a Doctrine model, and as long as your form field names are the same as your db column names that's all you have to do to add an address.
take a look - http://www.doctrine-project.org/
#3

[eluser]juddmuir[/eluser]
I was hoping for something more CI-specifc! But thank-you.




Theme © iAndrew 2016 - Forum software by © MyBB