mirror of
https://github.com/Oreolek/ifhub.club.git
synced 2024-06-16 23:00:51 +03:00
Дефолтные значения в дополнительных полях для типов - число, дробь, строка, чекбокс
This commit is contained in:
parent
0d7f14d353
commit
1757f80333
|
@ -33,6 +33,13 @@ class ModuleProperty_EntityValueTypeCheckbox extends ModuleProperty_EntityValueT
|
|||
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()
|
||||
{
|
||||
return $this->validateStandart('boolean');
|
||||
|
@ -44,4 +51,23 @@ class ModuleProperty_EntityValueTypeCheckbox extends ModuleProperty_EntityValueT
|
|||
$oValue = $this->getValueObject();
|
||||
$oValue->setValueInt($mValue ? 1 : 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,
|
||||
);
|
||||
}
|
||||
}
|
|
@ -33,6 +33,13 @@ class ModuleProperty_EntityValueTypeFloat extends ModuleProperty_EntityValueType
|
|||
return $this->getValueObject()->getValueFloat();
|
||||
}
|
||||
|
||||
public function getValueForForm()
|
||||
{
|
||||
$oValue = $this->getValueObject();
|
||||
$oProperty = $oValue->getProperty();
|
||||
return $oValue->_isNew() ? $oProperty->getParam('default') : $oValue->getValueFloat();
|
||||
}
|
||||
|
||||
public function validate()
|
||||
{
|
||||
return $this->validateStandart('number', array('integerOnly' => false));
|
||||
|
@ -58,4 +65,15 @@ class ModuleProperty_EntityValueTypeFloat extends ModuleProperty_EntityValueType
|
|||
}
|
||||
return $aRules;
|
||||
}
|
||||
|
||||
public function prepareParamsRaw($aParamsRaw)
|
||||
{
|
||||
$aParams = array();
|
||||
|
||||
if (isset($aParamsRaw['default'])) {
|
||||
$aParams['default'] = htmlspecialchars($aParamsRaw['default']);
|
||||
}
|
||||
|
||||
return $aParams;
|
||||
}
|
||||
}
|
|
@ -33,6 +33,13 @@ class ModuleProperty_EntityValueTypeInt extends ModuleProperty_EntityValueType
|
|||
return $this->getValueObject()->getValueInt();
|
||||
}
|
||||
|
||||
public function getValueForForm()
|
||||
{
|
||||
$oValue = $this->getValueObject();
|
||||
$oProperty = $oValue->getProperty();
|
||||
return $oValue->_isNew() ? $oProperty->getParam('default') : $oValue->getValueInt();
|
||||
}
|
||||
|
||||
public function validate()
|
||||
{
|
||||
return $this->validateStandart('number', array('integerOnly' => true));
|
||||
|
@ -58,4 +65,15 @@ class ModuleProperty_EntityValueTypeInt extends ModuleProperty_EntityValueType
|
|||
}
|
||||
return $aRules;
|
||||
}
|
||||
|
||||
public function prepareParamsRaw($aParamsRaw)
|
||||
{
|
||||
$aParams = array();
|
||||
|
||||
if (isset($aParamsRaw['default'])) {
|
||||
$aParams['default'] = htmlspecialchars($aParamsRaw['default']);
|
||||
}
|
||||
|
||||
return $aParams;
|
||||
}
|
||||
}
|
|
@ -33,6 +33,13 @@ class ModuleProperty_EntityValueTypeVarchar extends ModuleProperty_EntityValueTy
|
|||
return $this->getValueObject()->getValueVarchar();
|
||||
}
|
||||
|
||||
public function getValueForForm()
|
||||
{
|
||||
$oValue = $this->getValueObject();
|
||||
$oProperty = $oValue->getProperty();
|
||||
return $oValue->_isNew() ? $oProperty->getParam('default') : $oValue->getValueVarchar();
|
||||
}
|
||||
|
||||
public function validate()
|
||||
{
|
||||
return $this->validateStandart('string');
|
||||
|
@ -58,4 +65,15 @@ class ModuleProperty_EntityValueTypeVarchar extends ModuleProperty_EntityValueTy
|
|||
}
|
||||
return $aRules;
|
||||
}
|
||||
|
||||
public function prepareParamsRaw($aParamsRaw)
|
||||
{
|
||||
$aParams = array();
|
||||
|
||||
if (isset($aParamsRaw['default'])) {
|
||||
$aParams['default'] = htmlspecialchars($aParamsRaw['default']);
|
||||
}
|
||||
|
||||
return $aParams;
|
||||
}
|
||||
}
|
|
@ -317,7 +317,7 @@ class ModuleRbac extends ModuleORM
|
|||
}
|
||||
|
||||
/**
|
||||
* Загружает в кеш разрешения
|
||||
* Загружает в кеш разрешения
|
||||
*/
|
||||
protected function LoadPermissions()
|
||||
{
|
||||
|
@ -403,9 +403,9 @@ class ModuleRbac extends ModuleORM
|
|||
return false;
|
||||
}
|
||||
if (!($oRoleUser = $this->Rbac_GetRoleUserByFilter(array(
|
||||
'role_id' => $oRole->getId(),
|
||||
'user_id' => $iUserId
|
||||
)))
|
||||
'role_id' => $oRole->getId(),
|
||||
'user_id' => $iUserId
|
||||
)))
|
||||
) {
|
||||
/**
|
||||
* Добавляем
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{include "components/field/field.checkbox.tpl"
|
||||
name = "property[{$property->getId()}]"
|
||||
value = 1
|
||||
checked = $property->getValue()->getValueInt()
|
||||
value = $property->getParam( 'default_value' )
|
||||
checked = $property->getValue()->getValueForForm()
|
||||
note = $property->getDescription()
|
||||
label = $property->getTitle()}
|
|
@ -1,6 +1,6 @@
|
|||
{include "components/field/field.text.tpl"
|
||||
name = "property[{$property->getId()}]"
|
||||
value = $property->getValue()->getValueFloat()
|
||||
value = $property->getValue()->getValueForForm()
|
||||
classes = 'width-150'
|
||||
note = $property->getDescription()
|
||||
label = $property->getTitle()}
|
|
@ -1,6 +1,6 @@
|
|||
{include "components/field/field.text.tpl"
|
||||
name = "property[{$property->getId()}]"
|
||||
value = $property->getValue()->getValueInt()
|
||||
value = $property->getValue()->getValueForForm()
|
||||
classes = 'width-150'
|
||||
note = $property->getDescription()
|
||||
label = $property->getTitle()}
|
|
@ -1,5 +1,5 @@
|
|||
{include "components/field/field.text.tpl"
|
||||
name = "property[{$property->getId()}]"
|
||||
value = $property->getValue()->getValueVarchar()
|
||||
value = $property->getValue()->getValueForForm()
|
||||
note = $property->getDescription()
|
||||
label = $property->getTitle()}
|
Loading…
Reference in a new issue