Can't get set_value to work with array fields |
[eluser]Unknown[/eluser]
Hi all, I've been racking my brain over the following problem. I've got a form with arrays as field names but I can't get set_value to repopulate them properly. I've been trying to fix the problem myself and searching the forums for a relevant post, but I couldn't find one, so I'm going to post it myself. I've recreated the problem in the simplest of examples, namely the Form Validation tutorial in the CodeIgniter Manual. As I understand it, using array fields should work like this: Code: <input type="text" name="colors[]" value="<?php echo set_value('colors[]'); ?>" size="50" /> But it doesn't. I tried the following code (basically just adding square brackets to the username field) and this returns the value "Array" in the username field if the form does not validate. NB: In the real world code I use jQuery to dynamically add and remove form fields from a list and it is for this reason that I'd like to work with arrays. For the same reason I don't want to explicitly number the fields. How can I get this to work? Any help would be greatly appreciated. Here's the code I used in this example (I'm using the template engine): (I've not included the viewfile for the succes page) View myform.php: Code: <?php echo validation_errors(); ?> Controller form.php: Code: <?php
[eluser]phazei[/eluser]
Since it's in the docs, it must have been working in some version. Does anyone know what was the last version it worked before it broke?
[eluser]powdercoat[/eluser]
I have the exact same problem. forestclown came up with a temporary solution in this thread: http://ellislab.com/forums/viewthread/111929/ |
Welcome Guest, Not a member yet? Register Sign In |