Welcome Guest, Not a member yet? Register   Sign In
Pre-populated inputs and validation
#2

[eluser]Phil Sturgeon[/eluser]
Code:
// Just using the rules array to get a list of field names
foreach(array_keys($fields) as $field):
    $data[$field] = (isset($this->validation->$field)) ? $this->validation->$field : $this->something_model->getPropFromID($field, $foobarID);
endforeach;

I then just pass data to view. This is similar to what you have but you are going about it the wrong way.

Validation gives you errors, post will quietly get on with itself even without a value, so its best to test for validation with isset and if nothing there, shove in your default value from the DB.


Messages In This Thread
Pre-populated inputs and validation - by El Forum - 08-14-2007, 06:32 AM
Pre-populated inputs and validation - by El Forum - 08-14-2007, 09:31 AM
Pre-populated inputs and validation - by El Forum - 08-14-2007, 09:37 AM
Pre-populated inputs and validation - by El Forum - 08-14-2007, 09:45 AM
Pre-populated inputs and validation - by El Forum - 08-14-2007, 10:06 AM
Pre-populated inputs and validation - by El Forum - 08-14-2007, 03:25 PM
Pre-populated inputs and validation - by El Forum - 08-14-2007, 04:28 PM
Pre-populated inputs and validation - by El Forum - 08-17-2007, 09:29 AM
Pre-populated inputs and validation - by El Forum - 08-18-2007, 05:05 PM
Pre-populated inputs and validation - by El Forum - 10-20-2007, 12:03 PM
Pre-populated inputs and validation - by El Forum - 10-22-2007, 12:06 PM



Theme © iAndrew 2016 - Forum software by © MyBB