[eluser]gevans[/eluser]
I have the follwoing code;
Code:
function _validate_step($step)
{
//over-ride error messages
$this->form_validation->set_message('required', 'This field is required');
$this->form_validation->set_message('alpha_numeric', 'Field may only contain letters and numbers');
$this->form_validation->set_message('valid_email', 'This field must contain a valid email');
$this->form_validation->set_message('matches', 'The email fields must match');
//Run validation
if($this->form_validation->run("step$step") === FALSE)
{
/**
* if there's a validation error on a step
* earlier than the one being checked
* set to the earlier step
*/
if($step < $this->step_to_show)
$this->step_to_show = $step;
#echo validation_errors();
}
}
This is called by a different method where $step sent to this method is an int and is used to reference the following;
Code:
<?php
$config = array(
"step1" => array(
array(
"field" => "title",
"label" => "",
"rules" => "trim|required"
),
array(
"field" => "fname",
"label" => "",
"rules" => "trim|required|alpha_numeric"
),
array(
"field" => "email",
"label" => "",
"rules" => "trim|required|valid_email"
),
array(
"field" => "conf-email",
"label" => "",
"rules" => "trim|required|valid_email|matches[email]"
)
),
"step2" => array(
array(
"field" => "address-line-1",
"label" => "",
"rules" => "trim|required"
),
array(
"field" => "address-line-2",
"label" => "",
"rules" => "trim|required"
)
),
"step3" => array(
)
);
?>
Is this do-able, calling run a few times?
Cheers,
gevans