I fill out the Select Form element, and if I try to use HTML objects in a value, it is converted rather than displaying a special character.
This code:
$form->field_name->addMultiOption('value', ' • label');
Renders:
<option value="one">&nbsp;&bull; label</option>
But I want it to be:
<option value="one"> • label</option>
How can I use HTML objects here?
prompt
I dug up the code and found that it uses the function escape()from Zend View Abstract on the AND label and value. Maybe someone knows how to override / overload this function for a specific form element? I do not want to override this default behavior.
Function from class Zend_View_Helper_FormSelect
protected function _build($value, $label, $selected, $disable)
{
if (is_bool($disable)) {
$disable = array();
}
$opt = '<option'
. ' value="' . $this->view->escape($value) . '"'
. ' label="' . $this->view->escape($label) . '"';
if (in_array((string) $value, $selected)) {
$opt .= ' selected="selected"';
}
if (in_array($value, $disable)) {
$opt .= ' disabled="disabled"';
}
$opt .= '>' . $this->view->escape($label) . "</option>";
return $opt;
}
This is a class function Zend_View_Abstract:
private $_escape = 'htmlspecialchars';
public function escape($var)
{
if (in_array($this->_escape, array('htmlspecialchars', 'htmlentities'))) {
return call_user_func($this->_escape, $var, ENT_COMPAT, $this->_encoding);
}
return call_user_func($this->_escape, $var);
}