Issues

ZF-12019: Zend_Form_Element::isValid re-enables translation of validator messages

Description

Hello,

Zend_Form_Element::isValid accidentally re-enables translation of Zend_Validate_*.

Example:


$translator = new Zend_Translate_Adapter_Array();
$translator->addTranslation(array(
    'content' => array('isEmpty' => 'translated')
));
$element = new Zend_Form_Element_Text('foo');
$element->setTranslator($translator);
$element->addValidator('NotEmpty', true, array())
    ->setRequired(true);

$notEmpty = $element->getValidator('NotEmpty');
$notEmpty->setDisableTranslator(true);
$notEmpty->isValid('');
var_dump($notEmpty->getMessages());
// array
//  'isEmpty' => string 'Value is required and can't be empty' (length=36)

$element->isValid('');
var_dump($element->getMessages());
// array
//  'isEmpty' => string 'translated' (length=10)

$element->setDisableTranslator(true);
$element->isValid('');
var_dump($element->getMessages());
// array
//  'isEmpty' => string 'Value is required and can't be empty' (length=36)

Zend_Form_Element.php line 1386 is causing this error. Maybe Zend_Form_Element should become a flag to keep validators untouched.

Comments

No comments to display