Index: trunk/core/kernel/utility/formatters.php =================================================================== diff -u -r3523 -r3698 --- trunk/core/kernel/utility/formatters.php (.../formatters.php) (revision 3523) +++ trunk/core/kernel/utility/formatters.php (.../formatters.php) (revision 3698) @@ -142,31 +142,47 @@ class kOptionsFormatter extends kFormatter { -//function Format($value, $options, &$errors) function Format($value, $field_name, &$object, $format=null) { if ( is_null($value) ) return ''; $options = $object->GetFieldOptions($field_name); - if ( isset($format) ) $options['format'] = $format; $label = getArrayValue($options['options'], $value); - if( $label !== false ) - { - if( getArrayValue($options,'use_phrases') ) - { + if ($label !== false) { + if (getArrayValue($options, 'use_phrases')) { return $this->Application->Phrase($label); } - else - { + else { return $label; } } - else - { + else { return $value; } } + + function Parse($value, $field_name, &$object) + { + if ($value == '') return NULL; + + $options = $object->GetFieldOptions($field_name); + $use_phrases = getArrayValue($options, 'use_phrases'); + + $found = false; + foreach ($options['options'] as $option_key => $option_value) { + if ($use_phrases) { + $option_value = $this->Application->Phrase($option_value); + } + + if ($option_value == $value) { + $found = true; + break; + } + } + + return $found ? $option_key : $value; + } } /**