[eluser]ariok[/eluser]
Hi!
I have a question (that i hope could find an answer... -.-) about the validation class..
it's really hard for me understand how to manage a form where i have dinamic fields..
In my edit Form i have these steps:
1) load page taking data from db and set input value with this data.
2) send data
3) if there are some errors, load again edit form with $this->validation->fieldname value
rather than Db value as values for input field.
here some parts of my view code:
This is for input text field :
Code:
<input id="username" name="username" type="text" value="<? echo ($this->validation->username!=false or $this->validation->username_error!="") ? $this->validation->username : $userdata->username ;?>"/>
So for this situation is ok.. but if have dinamic fields in my form...
(like list of permissions with a checkbox to assign permissions to a users)... what i have to do?!?
I try to generate fields dinamicaly with this code in my controller
Code:
foreach ($queryAllGrp->result_array() as $ngrp) {
$fields["id".$ngrp['id']] = "id{$ngrp['id']}";
}
$this->validation->set_fields($fields);
and set view in this mode..($allGrp contain $queryAllGrp->result_array());
Code:
<table border='1'>
<? foreach($allGrp as $grp): ?>
<tr>
<td><input type="checkbox" name="id<?=$grp["id"]?>" value="<?=$grp["id"]?>" <? $var ="id".$grp['id']; echo ($this->validation->$var!=false) ? $this->validation->set_checkbox('id'.$grp["id"],$grp["id"]) : isMyGrp($grp["id"],$myGrp);?> /> </td>
</tr>
<? endforeach; ?>
</table>
But it seems that ($this->validation->$var!=false) is not the right way..
.. uhm... too confused... !!!!
is there a way to do this??
is not so strange to have dinamic form!!
thank you all .. and sorry for my terrible English