Hi there,

Zend_Validate_Float does not seem to validate right with locales
set. The function isValid() uses localeconv() to replace the thousands
separator and decimal point. But this only works if I have setup the php
locale with setlocale(). But if I do that, floatval() later on will
return a localized float value and so the validation fails.

I have fixed that for know with a custom float validator that uses a
global Zend_Locale object from Zend_Registry and falls back to the old
behavior if not set.

try {
    $locale = Zend_Registry::get('Zend_Locale');
    $valueFiltered = Zend_Locale_Format::getFloat(
        $valueString, array('locale' => $locale)
    );
} catch (Exception $e) {
    $locale = localeconv();
    $valueFiltered = str_replace($locale['thousands_sep'], '',
$valueString);
    $valueFiltered = str_replace($locale['decimal_point'], '.',
$valueFiltered);
}

Cheers Jan



Reply via email to