1

I have a big form with a lot of select elements with a lot of options each one. All translations work well (labels, descriptions, errors), but i don't want to translate the options shown in the select element.

The official guide says nothing about it, please check the following link: http://framework.zend.com/manual/1.12/en/zend.form.standardElements.html#zend.form.standardElements.select

However here it says: http://framework.zend.com/manual/1.12/en/zend.form.standardElements.html#zend.form.standardElements.multiselect "If a translation adapter is registered with the form and/or element, option values will be translated for display purposes. "

I can't remove the translation adapter, so my question is: Is it possible to ignore this element options?

Looking forward to your news. BR

Nacho Badia
  • 136
  • 2
  • 10

2 Answers2

0

Add $this->setTranslator(new Zend_Translate_Adapter_Array(array())); at beginning of your form. This will override default translator, and because new one is empty then it will not translate anything.

Volvox
  • 1,639
  • 1
  • 12
  • 10
  • Hi Volvox, i can't remove the adapter because the validation errors are not translated, and I need to show the errors in multilingual because the form it's complicated. I can translate labels, descriptions and placeholder without problems with one specific function, but i do not how to do that with the errors messages...You'd know how to do it? – Nacho Badia Apr 16 '15 at 07:48
0

The Zend_Form_Element_Multi have this:

if ($this->translatorIsDisabled()) {
    return false;
}

And there exist this method on Zend_Form_Element

public function setDisableTranslator($flag)
{
    $this->_translatorDisabled = (bool) $flag;
    return $this;
}

So I've created a method that extends Zend_Form_Element_Select and call:

$this->setDisableTranslator(true); 

That solved my question.

Nacho Badia
  • 136
  • 2
  • 10
  • I used this once but it did a little bit more than I wished for. It also disables field label translation and error translation. – Wolfer Sep 05 '17 at 13:00