Radicore Forum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » RADICORE development » Bug Reports » Enum Type and 0 index.
Enum Type and 0 index. [message #391] Mon, 13 November 2006 08:19 Go to previous message
johandewit is currently offline  johandewit
Messages: 25
Registered: May 2006
Location: Belgium
Junior Member
File : includes/std.validation.class.inc
Funtion : validatefield
        if ($fieldspec['type'] == 'enum') {
            debugbreak();
            // get enum array for this field
            $enum = $this->caller->getValRep($fieldname);
            // if we already have the value do not replace it
            if (!in_array($fieldvalue, $enum)) {
                // replace index number with text value
                $fieldvalue = $enum[$fieldvalue];
            } // if
        } // if


Problem ; If $fieldvalue=0, where 0 = array_index, the function in_array returns TRUE instead of FALSE. The fieldarray is not replaced with the $enum[0] value, resulting in validation error.

See also http://be.php.net/manual/en/function.in-array.php#61491

Changing line 111 to if (!in_array($fieldvalue, $enum, true))
solves this, and the fieldvalue is rpelaced with $enum[0] as intended.

At the end of this function, the enum type is passed to the validateNumber, (default case branch) which always results in an error message.

I've attached a patch against version 1.17.0 which makes the enum field type working (in my situation).

Greetings

Johan





 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: std.batch.inc
Next Topic: setOrderBy function working incorrectly
Goto Forum:
  


Current Time: Sun Nov 24 18:11:13 EST 2024

Total time taken to generate the page: 0.00963 seconds