Function set_value() not working as expected |
[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...
[eluser]kyleb[/eluser]
This still not being patched blows my mind. I have to patch every CI install with this.
[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.
[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.
[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.
[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.
[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?
[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]))
[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 ...
[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 |
Welcome Guest, Not a member yet? Register Sign In |