Welcome Guest, Not a member yet? Register   Sign In
form_prep, form helper issues
#4

[eluser]skiff_pt[/eluser]
I have experienced the same problem as violinchris.

After i looked into the original form_prep code i found the following:

Code:
function form_prep($str = '', $field_name = '')
    {
        
        static $prepped_fields = array();

        // if the field name is an array we do this recursively
        if (is_array($str))
        {
            foreach ($str as $key => $val)
            {
                $str[$key] = form_prep($val);
            }

            return $str;
        }

        if ($str === '')
        {
            return '';
        }

        // we've already prepped a field with this name
        // @todo need to figure out a way to namespace this so
        // that we know the *exact* field and not just one with
        // the same name
        if (isset($prepped_fields[$field_name]))
        {
            return $str;
        }

        $str = htmlspecialchars($str);
        // In case htmlspecialchars misses these.
        $str = str_replace(array("'", '"'), array("'", """), $str);

        if ($field_name != '')
        {
            $prepped_fields[$field_name] = $str;
        }

        return $str;
    }

There is a static array that stores all previously prepped_fields.

Question:
Is there a reason why in case a field is already prepped form_prep returns the un_preped $str:
Code:
if (isset($prepped_fields[$field_name]))
        {
            return $str;
        }

why not returning the previously stored prepped string?
example:
Code:
if (isset($prepped_fields[$field_name]))
        {
            return $prepped_fields[$field_name];
        }

Regards


Messages In This Thread
form_prep, form helper issues - by El Forum - 08-02-2010, 12:53 PM
form_prep, form helper issues - by El Forum - 08-02-2010, 02:21 PM
form_prep, form helper issues - by El Forum - 08-02-2010, 04:20 PM
form_prep, form helper issues - by El Forum - 01-07-2011, 07:04 PM



Theme © iAndrew 2016 - Forum software by © MyBB