* */ /** * Объект управления типом checkbox * * @package application.modules.property * @since 2.0 */ class ModuleProperty_EntityValueTypeCheckbox extends ModuleProperty_EntityValueType { public function getValueForDisplay() { return (bool)$this->getValueObject()->getValueInt(); } public function getValueForForm() { $oValue = $this->getValueObject(); $oProperty = $oValue->getProperty(); return $oValue->_isNew() ? $oProperty->getParam('default') : $oValue->getValueInt(); } public function validate() { $sValue = $this->getValueForValidate(); $this->setValueForValidate($sValue ? 1 : 0); return true; } public function setValue($mValue) { $this->resetAllValue(); $oValue = $this->getValueObject(); $oProperty = $oValue->getProperty(); $oValue->setValueInt($mValue ? $oProperty->getParam('default_value') : 0); } public function prepareParamsRaw($aParamsRaw) { $aParams = array(); $aParams['default'] = isset($aParamsRaw['default']) ? true : false; if (isset($aParamsRaw['default_value'])) { $aParams['default_value'] = htmlspecialchars($aParamsRaw['default_value']); } return $aParams; } public function getParamsDefault() { return array( 'default_value' => 1, ); } }