Posted by Ricardo Buquet (enkil2003) on 2012-03-06T16:43:54.000+0000
Yes the html5 attribute, i was looking, but it seems that it only happends when you use an ini file. Because if you are using a php you could set the translation once you assign the value. But I'm assigning it through the ini file using a key like 'section.name.error', I guess it treats all the attributes the same way. And doesn't take into account that that kind of attribut should be translated.
I dont know if the solution would be adding a specific way to declare the placeholders in the ini when the form reads it, or allow ini files to run functions/methods on the assigned values.
Posted by Ricardo Buquet (enkil2003) on 2012-03-06T16:50:52.000+0000
May be the method Zend_Form_Element::setAttrib could take into account that kind of stuff:
public function setAttrib($name, $value)
{
$name = (string) $name;
if ('_' == $name[0]) {
require_once 'Zend/Form/Exception.php';
throw new Zend_Form_Exception(sprintf('Invalid attribute "%s"; must not contain a leading underscore', $name));
}
if (null === $value) {
unset($this->$name);
} else {
$this->$name = $value;
}
return $this;
}
Posted by Ricardo Buquet (enkil2003) on 2012-03-06T17:56:42.000+0000
A simple solution would be:
public function setAttrib($name, $value)
{
$name = (string) $name;
if ('_' == $name[0]) {
require_once 'Zend/Form/Exception.php';
throw new Zend_Form_Exception(sprintf('Invalid attribute "%s"; must not contain a leading underscore', $name));
}
if (null === $value) {
unset($this->$name);
} else {
=====================================================================================
if ($this->getView()->doctype()->isHtml5() && $name === 'placeholder') {
$value = $view->translate($value);
}
=====================================================================================
$this->$name = $value;
}
return $this;
}
Posted by Frank Brückner (frosch) on 2012-03-08T12:18:16.000+0000
Posted by Ricardo Buquet (enkil2003) on 2012-03-08T12:39:22.000+0000
A placeholder is an special property as could be title and alt, those properties should be translated without any other decoration or specification.
I think it should be transparent to code using the library.
Posted by Frank Brückner (frosch) on 2012-03-12T19:08:18.000+0000
The best solution would be to move the translation into the view layer, but in ZF1 it is inconsistent to label, description, …
But it is also a bad idea to check the doctype in Zend_Form!
Comments
Posted by Frank Brückner (frosch) on 2012-03-06T16:40:36.000+0000
Do you mean the placeholder attribute in HTML5?
Posted by Ricardo Buquet (enkil2003) on 2012-03-06T16:43:54.000+0000
Yes the html5 attribute, i was looking, but it seems that it only happends when you use an ini file. Because if you are using a php you could set the translation once you assign the value. But I'm assigning it through the ini file using a key like 'section.name.error', I guess it treats all the attributes the same way. And doesn't take into account that that kind of attribut should be translated. I dont know if the solution would be adding a specific way to declare the placeholders in the ini when the form reads it, or allow ini files to run functions/methods on the assigned values.
Posted by Ricardo Buquet (enkil2003) on 2012-03-06T16:50:52.000+0000
May be the method Zend_Form_Element::setAttrib could take into account that kind of stuff:
Posted by Ricardo Buquet (enkil2003) on 2012-03-06T17:56:42.000+0000
A simple solution would be:
Posted by Frank Brückner (frosch) on 2012-03-08T12:18:16.000+0000
Hi Ricardo, {{Zend_Form_Element}} has his own translator: Zend_Form_Element::getTranslator()
Maybe a new decorator is an option, similar to Zend_Form_Decorator_Tooltip.
Posted by Ricardo Buquet (enkil2003) on 2012-03-08T12:39:22.000+0000
A placeholder is an special property as could be title and alt, those properties should be translated without any other decoration or specification. I think it should be transparent to code using the library.
Posted by Frank Brückner (frosch) on 2012-03-12T19:08:18.000+0000
The best solution would be to move the translation into the view layer, but in ZF1 it is inconsistent to label, description, … But it is also a bad idea to check the doctype in Zend_Form!