![]() |
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 - 05-04-2011 [eluser]Unknown[/eluser] If you are still struggling with set_value() to repopulate form values. Just use traditional php way of doing : e.g <input type='text' name='firstname' value="<?php echo set_value('firstname'); ?>" /> replace with --- <input type='text' name='firstname' value="<?php echo (isset($_REQUEST['firstname'])) ? $_REQUEST['firstname'] : ''; ?>" /> and bingo it works like charm... Function set_value() not working as expected - El Forum - 05-05-2011 [eluser]kyleb[/eluser] This still not being patched blows my mind. I have to patch every CI install with this. Function set_value() not working as expected - El Forum - 06-21-2011 [eluser]kyleb[/eluser] Is this still an issue? I haven't worked with a new install of CI in awhile; still maintaining my old 1.x applications. If so, is this on the radar at all? It's really ridiculous. Function set_value() not working as expected - El Forum - 08-05-2011 [eluser]Unknown[/eluser] Yep, this is a frustrating bug. Seems like it should be such an easy fix; should be rolled into the main trunk. Function set_value() not working as expected - El Forum - 08-05-2011 [eluser]Aken[/eluser] Who knows if it's on the radar, but it's been brought up in Reactor and Core (going on two years now) and it is still not implemented. Function set_value() not working as expected - El Forum - 04-03-2012 [eluser]Ben Swinburne[/eluser] A note to those using the fix by jbreitweiser found here http://ellislab.com/forums/viewthread/96617/P15/#689642, There's a slight change required in the function set_value_array This line Code: if (($field == '' OR $value == '') OR ($field != $value)) Should be changed to Code: if (($field === '' OR $value === '') OR ($field != $value)) I found when sending zero as a value of a field, it equated to '' which meant that '' was returned, not the default value as expected. Function set_value() not working as expected - El Forum - 05-14-2012 [eluser]w1n78[/eluser] i'm trying to use jbreitweiser's fix (http://ellislab.com/forums/viewthread/96617/P15/#689642) but rather than edit the functions in /system/libraries/Form_validation.php file i created a /application/helpers/MY_form_helper.php file and pasted the script. i am getting a "Fatal error: Using $this when not in object context..." error. the line where the error is occurring has the following... Code: if ( ! isset($this->_field_data[$field])) any ideas? Function set_value() not working as expected - El Forum - 07-28-2012 [eluser]GreGre[/eluser] You are using $this out of the object context. Helpers are not classes, they are plain functions. If you want to use the codeigniter object inside a function you should instantiate it (inside each function) like this Code: $CI = & get_instance(); An than use $CI instead of $this Code: if ( ! isset($CI->_field_data[$field])) Function set_value() not working as expected - El Forum - 07-28-2012 [eluser]GreGre[/eluser] BTW the bug still isn't fixed in 2.1.2! But after all, it's allways a good idea to setup rules for all fields, just to check for the right data type ... Function set_value() not working as expected - El Forum - 08-26-2012 [eluser]FireStarter[/eluser] [quote author="kyleb" date="1304633954"]This still not being patched blows my mind. I have to patch every CI install with this.[/quote] Has this issue really still not been patched, in 2012 - 4 years following the topic being opened? It's really bugging me, does anybody know the best way to patch it in the latest version of CodeIgniter? Preferably with a MY_form_helper rather than hacking the core. Thanks |