_escapeLabel = (bool) $flag;
return $this;
}
public function getEscapeLabel()
{
return $this->_escapeLabel;
}
public function formSelect($name, $value = null, $attribs = null,
$options = null, $listsep = "
\n")
{
$info = $this->_getInfo($name, $value, $attribs, $options, $listsep);
$name = $id = $value = $attribs = $options = $listsep = $disable = null;
extract($info); // name, id, value, attribs, options, listsep, disable
// force $value to array so we can compare multiple values to multiple
// options; also ensure it's a string for comparison purposes.
$value = array_map('strval', (array) $value);
// check if element may have multiple values
$multiple = '';
if (substr($name, -2) == '[]') {
// multiple implied by the name
$multiple = ' multiple="multiple"';
}
if (isset($attribs['escapeLabel'])) {
$this->setEscapeLabel($attribs['escapeLabel']);
unset($attribs['escapeLabel']);
}
if (isset($attribs['multiple'])) {
// Attribute set
if ($attribs['multiple']) {
// True attribute; set multiple attribute
$multiple = ' multiple="multiple"';
// Make sure name indicates multiple values are allowed
if (!empty($multiple) && (substr($name, -2) != '[]')) {
$name .= '[]';
}
} else {
// False attribute; ensure attribute not set
$multiple = '';
}
unset($attribs['multiple']);
}
// now start building the XHTML.
$disabled = '';
if (true === $disable) {
$disabled = ' disabled="disabled"';
}
// Build the surrounding select element first.
$xhtml = '";
return $xhtml;
}
protected function _build($value, $label, $selected, $disable, $optionClasses = [])
{
if (is_bool($disable)) {
$disable = [];
}
$class = null;
if (array_key_exists($value, $optionClasses)) {
$class = $optionClasses[$value];
}
$opt = '";
return $opt;
}
protected function escapeLabel($label)
{
if ($this->getEscapeLabel()) {
return $this->view->escape($label);
}
return $label;
}
}