mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Adding fix for Ticket #1005
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@3105 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
a1ee0d93c4
commit
ae3a8d0f9e
1 changed files with 19 additions and 9 deletions
|
@ -255,23 +255,33 @@ class HtmlHelper extends Helper {
|
|||
function checkbox($fieldName, $title = null, $htmlAttributes = null, $return = false) {
|
||||
$value = $this->tagValue($fieldName);
|
||||
$notCheckedValue = 0;
|
||||
if (isset($htmlAttributes['value'])) {
|
||||
$htmlAttributes['checked']=($htmlAttributes['value'] == $value) ? 'checked' : null;
|
||||
|
||||
if ($htmlAttributes['checked'] == '0') {
|
||||
if (isset($htmlAttributes['checked'])) {
|
||||
if ($htmlAttributes['checked'] == 'checked' || intval($htmlAttributes['checked']) === 1 || $htmlAttributes['checked'] === true) {
|
||||
$htmlAttributes['checked'] = 'checked';
|
||||
} else {
|
||||
$htmlAttributes['checked'] = null;
|
||||
$notCheckedValue = -1;
|
||||
}
|
||||
} else {
|
||||
$model = new $this->model;
|
||||
$db =& ConnectionManager::getDataSource($model->useDbConfig);
|
||||
$value = $db->boolean($value);
|
||||
$htmlAttributes['checked'] = $value ? 'checked' : null;
|
||||
$htmlAttributes['value'] = 1;
|
||||
if (isset($htmlAttributes['value'])) {
|
||||
$htmlAttributes['checked'] = ($htmlAttributes['value'] == $value) ? 'checked' : null;
|
||||
|
||||
if ($htmlAttributes['checked'] == '0') {
|
||||
$notCheckedValue = -1;
|
||||
}
|
||||
} else {
|
||||
$model = new $this->model;
|
||||
$db =& ConnectionManager::getDataSource($model->useDbConfig);
|
||||
$value = $db->boolean($value);
|
||||
$htmlAttributes['checked'] = $value ? 'checked' : null;
|
||||
$htmlAttributes['value'] = 1;
|
||||
}
|
||||
}
|
||||
if (!isset($htmlAttributes['id'])) {
|
||||
$htmlAttributes['id'] = $this->model . Inflector::camelize($this->field);
|
||||
}
|
||||
$output = $this->hidden($fieldName, array('value' => $notCheckedValue), true);
|
||||
$output = $this->hidden($fieldName, array('value' => $notCheckedValue, 'id' => $htmlAttributes['id'] . '_'), true);
|
||||
$output .= sprintf($this->tags['checkbox'], $this->model, $this->field, $this->_parseAttributes($htmlAttributes, null, '', ' '));
|
||||
return $this->output($output, $return);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue