Using Arrays as Field Names - Validation bug? |
[eluser]Vicente Russo[/eluser]
Hi, On my last topic, I was trying to use dynamic validation, and I found using arrays as fieldnames worked for me. But when I repopulate the form, they return the string "Array" on every 'title[]' input, not the actual value. Controller Code: Code: $this->form_validation->set_rules('title[]', 'Title', 'required'); View Code: Code: <input name="title[]" type="text" value="<?=set_value('title[]')?>" /> If I use Code: set_value('title['.$index.']')?> "Or to re-populate the field you would use:" Code: <input type="text" name="options[]" value="<?php echo set_value('options[]'); ?>" size="50" /> So, can someone help me? Thanks!
[eluser]forestclown[/eluser]
Hi there, I also wanted to know how it can be done, and searched the forum and found your thread. Although I couldn't find any answers yet, here is what I did. Base on your example: Code: <input name="title[]" type="text" value="<?=set_value('title[]')?>" /> Change to something like below: Code: <?php $title = set_value('title[]'); ?> I assume you are using a loop to output them, so continue from the above example base on your scenario, change from: Code: <?=set_value('title['.$index.']')?> to something like: Code: <?=$title['.$index.']')?> I am still figuring out how to output errors that ties to the specific item, as it will show the errors for all items if I use Code: <?=form_error('title[]')?>
[eluser]powdercoat[/eluser]
I'm trying to find a solution to this too. Thanks for the quick fix forestclown!
[eluser]Evil Wizard[/eluser]
I'm not sure if it is a bug, or just an oversight, but I came across a similar problem a while back, and then came up with a solution, maybe it will assist you too. http://ellislab.com/forums/viewthread/111929/
[eluser]Dam1an[/eluser]
[quote author="Evil Wizard" date="1245696633"]I'm not sure if it is a bug, or just an oversight, but I came across a similar problem a while back, and then came up with a solution, maybe it will assist you too. http://ellislab.com/forums/viewthread/111929/[/quote] you seem to be linking to this thread lol
[eluser]Evil Wizard[/eluser]
oooops ty Dam1on, I'm having a little klipper trouble today, the url should have been http://ellislab.com/forums/viewthread/115253/ |
Welcome Guest, Not a member yet? Register Sign In |