Welcome Guest, Not a member yet? Register   Sign In
Prefill forms from DB array
#4

[eluser]Phil Sturgeon[/eluser]
CI has nothing like this built in but you can hack the same sort of effect.

in your controller after your validation rules have been set enter:

Code:
$this->data->whatever = $this->whatever_model->getWhatever($id);

foreach(array_keys($rules) as $field) {
    if(isset($_POST[$field])) {
        $this->data->whatever->{$field} = $this->validation->{$field};
    }
}

Then in your views, you can just have:

Code:
<?=form_input('order', $whatever->order);?>


It might look a little crazy, but it works very well. You are basically getting the data from the db, then unless the POST variable has a more up to date version, you are putting the DB values into the form.

Would be nice to have a way of doing this a little easier, but I think getting too involved in CRUD automation is a very bad idea. Every system I have ever used to do this has made my life harder, more stressful and less productive! >.<


Messages In This Thread
Prefill forms from DB array - by El Forum - 09-28-2008, 04:10 PM
Prefill forms from DB array - by El Forum - 09-28-2008, 07:34 PM
Prefill forms from DB array - by El Forum - 09-29-2008, 02:32 AM
Prefill forms from DB array - by El Forum - 09-30-2008, 07:18 AM
Prefill forms from DB array - by El Forum - 09-30-2008, 09:12 AM
Prefill forms from DB array - by El Forum - 09-30-2008, 03:12 PM
Prefill forms from DB array - by El Forum - 10-01-2008, 02:25 AM
Prefill forms from DB array - by El Forum - 10-01-2008, 04:12 AM
Prefill forms from DB array - by El Forum - 10-01-2008, 04:49 AM



Theme © iAndrew 2016 - Forum software by © MyBB