![]() |
Function set_value() not working as expected - 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: Function set_value() not working as expected (/showthread.php?tid=13106) |
Function set_value() not working as expected - El Forum - 02-08-2009 [eluser]cwt137[/eluser] [quote author="ifew" date="1234095714"]hello patch from cwt137 i can't use this, it return first field value to every input[/quote] Can you post a test case where my patch doesn't work? Then I can see what I can do to fix it. Function set_value() not working as expected - El Forum - 02-08-2009 [eluser]ifew[/eluser] [quote author="cwt137" date="1234131367"][quote author="ifew" date="1234095714"]hello patch from cwt137 i can't use this, it return first field value to every input[/quote] Can you post a test case where my patch doesn't work? Then I can see what I can do to fix it.[/quote] in view Code: <input type=‘text’ name=“optoin[]” size=“30” value=”<?=set_value(‘optoin[]’); ?>”/> in rule config Code: array( it's return value from first field to all but if use indexing number to optoin[] field and rule. (such as optoin[0],optoin[1],..) it's ok ps. sorry i'm bad english Function set_value() not working as expected - El Forum - 02-24-2009 [eluser]kandmcreative[/eluser] I think we definitely need a solution where the array index is not needed, since often times, we don't know how many elements we will have. Function set_value() not working as expected - El Forum - 07-15-2009 [eluser]Helmet[/eluser] Please fix this. It drives me bananas to be forced to put worthless lines like: $this->form_validation->set_rules('field','field name',''); into my code just so that I can repopulate my field. Function set_value() not working as expected - El Forum - 07-15-2009 [eluser]gigas10[/eluser] [quote author="kandmcreative" date="1235519540"]I think we definitely need a solution where the array index is not needed, since often times, we don't know how many elements we will have.[/quote] ever heard of a loop? Function set_value() not working as expected - El Forum - 11-10-2009 [eluser]tison[/eluser] Is there a fix for this - without adding an empty rule? Subscribing... Function set_value() not working as expected - El Forum - 11-10-2009 [eluser]tison[/eluser] For a quick fix, I've created this function to easily set empty rules - so that all fields get re-populated: In /helpers/MY_form_helper.php Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); And in your controller: Code: set_empty_rules(array('address'=>'Address','city'=>'City','state'=>'State','zip'=>'Zip')); Function set_value() not working as expected - El Forum - 12-13-2009 [eluser]Tooker[/eluser] Had this same problem using 1.7.2 and google took me here. This is still unresolved. Regards, Rob Function set_value() not working as expected - El Forum - 01-01-2010 [eluser]jbreitweiser[/eluser] I looked through the code and the problem is the the set_value() function will call the set_value function in the form_validation class. The form validation class only has the post data for the fields set up with a form validation. This needs to happen because during validation a callback function can return a new value instead of true or false. All of the set_value functions need to check if there is a form validation defined, and if so use the input->post value. If I get something to work I will post some code. Function set_value() not working as expected - El Forum - 01-02-2010 [eluser]jbreitweiser[/eluser] Fixed extra space in last return statement. Replace the set_value, set_select, set_radio, and set_checkbox in the /system/libraries/Form_validation.php file. Basically if the form validator does not have the value, the code checks the input class. Code: /** |