Hello,
I was giving a try to the formSelect helper in one of my forms as below:
echo $this->formSelect('box_id', $this->data->box_id, null, $this->boxes);
I have two questions:
- option labels are not translated. There is a setTranslator()
function in the helper code but I could not figure out how to use it.
also -if i am not mistaken- the translate function is only used if the
option is an array:
//Zend/View/Helper/FormSelect.php
foreach ((array) $options as $opt_value => $opt_label) {
if (is_array($opt_label)) {
$opt_disable = '';
if (is_array($disable) && in_array($opt_value, $disable)) {
$opt_disable = ' disabled="disabled"';
}
if (null !== $translator) {
$opt_value = $translator->translate($opt_value);
}
$list[] = '<optgroup'
. $opt_disable
. ' label="' . $this->view->escape($opt_value) .'">';
foreach ($opt_label as $val => $lab) {
$list[] = $this->_build($val, $lab, $value, $disable);
}
$list[] = '</optgroup>';
} else {
$list[] = $this->_build($opt_value, $opt_label,
$value, $disable);
}
}
Am I wrong?
In other words, even If I set the translator in anyway, my select box
options will not be translated unless I use optgroup type
select/options.
Second question is, is there a way to push a "--select--" type option
to the beginning via this helper? I could not find any parameter
and maybe i am missing something?
TiA
scs