php-censor/src/B8Framework/Form/Element/Checkbox.php
2016-06-23 21:18:41 +06:00

48 lines
836 B
PHP
Executable file

<?php
namespace b8\Form\Element;
use b8\View,
b8\Form\Input;
class Checkbox extends Input
{
protected $_checked;
protected $_checkedValue;
public function getCheckedValue()
{
return $this->_checkedValue;
}
public function setCheckedValue($value)
{
$this->_checkedValue = $value;
}
public function setValue($value)
{
if(is_bool($value) && $value == true)
{
$this->_value = $this->getCheckedValue();
$this->_checked = true;
return;
}
if($value == $this->getCheckedValue())
{
$this->_value = $this->getCheckedValue();
$this->_checked = true;
return;
}
$this->_value = $value;
$this->_checked = false;
}
public function _onPreRender(View &$view)
{
parent::_onPreRender($view);
$view->checkedValue = $this->getCheckedValue();
$view->checked = $this->_checked;
}
}