[eluser]philstan[/eluser]
Hi everyone,
Although the form validation seems to stop the input of an incomplete form, I'm having difficulty getting CI to give me a validation message on a dynamically generated form.
Here is the code in the View:
Code:
case "Agree Disagree";
echo "<div class=\"question\">".$fieldset->question."</div>";
//put in the answer options
echo "<div class=\"answer\">";
echo form_error($fieldset->qid);
echo "<select name=".$fieldset->qid.">";
echo "<option select=\"selected\" value=\"\" >Select one...</option>";
foreach($answers as $value)
{
if($value->group_name == "Agree Disagree")
{
echo "<option value=".$value->id.">".$value->answer."</option>";
}
}
echo "</select>";
echo "</div>";
//clear the floats
echo "<div class=\"clear\"> </div>";
break;
Here is the submit() in the controller:
Code:
$validate = $_POST;
foreach($validate as $key => $value)
{
$this->form_validation->set_rules('.$key.', 'Question', 'required');
}
Dies anyone know why this doesn't work or how to get the thing to work.
Thanks Philip