Validation & Re-populating form & set_value() don't work |
[eluser]ReyPM[/eluser]
Hi every: I'm trying to validate and repopulate a form but isn't working :grrr: This is the function that handles validation (not include all the fields because are a lot): Code: public function add() { Code: <input class="form-txt" type="text" name="initial_inventory_91" id="initial_inventory_91" value="<?php echo isset($initial_inventory_91)?set_value($initial_inventory_91):'' ?>" /> But if the form contains errors never is populated with previous values, why? I've see this two post: - http://ellislab.com/forums/viewthread/138002/ - http://ellislab.com/forums/viewthread/135367/ But didn't found the solution. Any help? Cheers and thanks in advance ;-)
[eluser]oppenheimer[/eluser]
First, in your view, I think it should be: Code: <input class="form-txt" type="text" name="initial_inventory_91" id="initial_inventory_91" value="<?php echo set_value('initial_inventory_91');?>" /> Second, in your controller I think your set_rules should be: Code: $this->form_validation->set_rules('initial_inventory_91','Inventario Inicial 91', 'trim|required|xss_clean');
[eluser]Nisha S.[/eluser]
There is no need for the isset checking. Just put your only your rules in Controller. set_value function accepts default value as one of the paramter, you can use it instead of using isset. If need more help you can refer it from my blog. |
Welcome Guest, Not a member yet? Register Sign In |