0,
'multiSeparators' => [],
];
if (array_key_exists('columns', $attribs)) {
$info['columns'] = (int) $attribs['columns'];
unset($attribs['columns']);
}
if (array_key_exists('multiSeparators', $attribs)) {
$info['multiSeparators'] = $attribs['multiSeparators'];
unset($attribs['multiSeparators']);
}
$_info = parent::_getInfo($name, $value, $attribs, $options, $listsep);
$info = array_merge($info, $_info);
return $info;
}
public function formRadio($name, $value = null, $attribs = null,
$options = null, $listsep = "
\n")
{
$info = $this->_getInfo($name, $value, $attribs, $options, $listsep);
extract($info); // name, value, attribs, options, listsep, disable
// retrieve attributes for labels (prefixed with 'label_' or 'label')
$label_attribs = [];
foreach ($attribs as $key => $val) {
$tmp = false;
$keyLen = strlen($key);
if ((6 < $keyLen) && (substr($key, 0, 6) == 'label_')) {
$tmp = substr($key, 6);
} elseif ((5 < $keyLen) && (substr($key, 0, 5) == 'label')) {
$tmp = substr($key, 5);
}
if ($tmp) {
// make sure first char is lowercase
$tmp[0] = strtolower($tmp[0]);
$label_attribs[$tmp] = $val;
unset($attribs[$key]);
}
}
$labelPlacement = 'append';
foreach ($label_attribs as $key => $val) {
switch (strtolower($key)) {
case 'placement':
unset($label_attribs[$key]);
$val = strtolower($val);
if (in_array($val, ['prepend', 'append'])) {
$labelPlacement = $val;
}
break;
}
}
// the radio button values and labels
$options = (array) $options;
// build the element
$xhtml = '';
$list = [];
// should the name affect an array collection?
$name = $this->view->escape($name);
if ($this->_isArray && ('[]' != substr($name, -2))) {
$name .= '[]';
}
// ensure value is an array to allow matching multiple times
$value = (array) $value;
// XHTML or HTML end tag?
$endTag = ' />';
if (($this->view instanceof Zend_View_Abstract) && !$this->view->doctype()->isXhtml()) {
$endTag = '>';
}
// add radio buttons to the list.
// require_once 'Zend/Filter/Alnum.php';
$filter = new Zend_Filter_Alnum();
foreach ($options as $opt_value => $opt_label) {
// Should the label be escaped?
if ($escape) {
$opt_label = $this->view->escape($opt_label);
}
// is it disabled?
$disabled = '';
if (true === $disable) {
$disabled = ' disabled="disabled"';
} elseif (is_array($disable) && in_array($opt_value, $disable)) {
$disabled = ' disabled="disabled"';
}
// is it checked?
$checked = '';
if (in_array($opt_value, $value)) {
$checked = ' checked="checked"';
}
// generate ID
$optId = $id . '-' . $filter->filter($opt_value);
// Wrap the radios in labels
$radio = Qs_Array::get($multiSeparators, $opt_value . '[beforeLabel]', '')
. ''
. Qs_Array::get($multiSeparators, $opt_value . '[afterLabel]', '')
. '';
// add to the array of radio buttons
$list[] = $radio;
}
if ($columns > 1) {
$xhtml = '
' . implode($listsep, array_slice($list, $i * $ipc, $ipc)) . ' | '; } $xhtml .= '