CI 1.7svn array form_validation problem - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: CI 1.7svn array form_validation problem (/showthread.php?tid=12212) |
CI 1.7svn array form_validation problem - El Forum - 10-10-2008 [eluser]CI shocki[/eluser] Hi guys, I have the following validation config: Code: array( in my view I have Code: <textarea name="description_teaser[]" id="elm1"><?php echo set_value('description_teaser[]'); ?></textarea> When repopulating the form this does not work. Instead of the expected result every textarea field ist filled with the text "array" Any ideas? Regards shocki CI 1.7svn array form_validation problem - El Forum - 10-10-2008 [eluser]xwero[/eluser] IMO If you want to repopulate fields that are a part of an array you should specify the key(s). Let's say you do something like below in your view Code: <?php foreach($fields as $field): ?> I think if you are going to use arrays you shouldn't expect the library to almost read your mind. It's possible but i think the performance hit will be significant. CI 1.7svn array form_validation problem - El Forum - 10-10-2008 [eluser]CI shocki[/eluser] something like that is working. Code: <?php $var=set_value('description_teaser[]'); echo is_array(description_teaser[]) ? $var[0] : ''; ?> But to me this solution doesn't make that much sense. Rick, Derek? Isn't that meant to be an automatic approach? CI 1.7svn array form_validation problem - El Forum - 10-10-2008 [eluser]xwero[/eluser] This is the library's set_value code Code: /** CI 1.7svn array form_validation problem - El Forum - 10-10-2008 [eluser]CI shocki[/eluser] Yeah it seems like it. This is from the manual: Quote:Or to re-populate the field you would use: Code: <input type="text" name="options[]" value="<?php echo set_value('options[]'); ?>" size="50" /> This would always output "array". So this example doesn't really make sense. CI 1.7svn array form_validation problem - El Forum - 10-10-2008 [eluser]xwero[/eluser] The array handling of the library has some rough edges that need to be polished before it gets released. But if you have a good idea how to fix it join the thread on the Form_validation library started by Rick. |