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

[eluser]Phil Sturgeon[/eluser]
Okie doke, using validation right? You make your big

Code:
<?
class Form extends Controller(){

function form1($farmerID = 0){

$rules = array(
   'wellies' = 'required|greather_than[1]',
   'velcrow_gloves' = 'required',
   'lonley_sheep' = 'required'
);

$fields = array(
   'wellies' = 'Rubber Boots',
   'velcrow_gloves' = 'Sticky Gloves',
   'lonley_sheep' = 'Critter Companion'
);

// run validation functions
$this->validation->whatever...

if(validation == true):
echo "Right on brother, have some fun with that critter!";
redirect('goto/quiet_barn');
else:
echo $this->validation->error_string;
endif;

$default_data = $this->farmer->getSheepRelationData($farmerID);

// Foreach form field
foreach(array_keys($fields) as $field):
    $data[$field] = (isset($this->validation->$field)) ? $this->validation->$field : $default_data[$field];
endforeach;


$this->load->view('whatever', $data);

}
}
?>


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