Welcome Guest, Not a member yet? Register   Sign In
Function set_value() not working as expected
#31

[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...
#32

[eluser]kyleb[/eluser]
This still not being patched blows my mind. I have to patch every CI install with this.
#33

[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.
#34

[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.
#35

[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.
#36

[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.
#37

[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?
#38

[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]))
#39

[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 ...
#40

[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




Theme © iAndrew 2016 - Forum software by © MyBB