本文整理汇总了PHP中CJavaScript::jsonDecode方法的典型用法代码示例。如果您正苦于以下问题:PHP CJavaScript::jsonDecode方法的具体用法?PHP CJavaScript::jsonDecode怎么用?PHP CJavaScript::jsonDecode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CJavaScript
的用法示例。
在下文中一共展示了CJavaScript::jsonDecode方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionSaveSri
public function actionSaveSri()
{
if (Yii::app()->request->isPostRequest) {
$model = new VSServiciosSRI();
$objEnt = isset($_POST['SERVER']) ? CJavaScript::jsonDecode($_POST['SERVER']) : array();
$accion = isset($_POST['ACCION']) ? $_POST['ACCION'] : "";
if ($accion == "Create") {
//$resul = $model->insertarServidor($objEnt);
} else {
$resul = $model->actualizarServiciosSRI($objEnt);
}
if ($resul) {
$arroout["status"] = "OK";
$arroout["type"] = "tbalert";
$arroout["label"] = "success";
$arroout["error"] = "false";
$arroout["message"] = Yii::t('EXCEPTION', '<strong>Well done!</strong> your information was successfully saved.');
$arroout["data"] = null;
} else {
$arroout["status"] = "NO_OK";
$arroout["type"] = "tbalert";
$arroout["label"] = "error";
$arroout["error"] = "true";
$arroout["message"] = Yii::t('EXCEPTION', 'Invalid request. Please do not repeatt this request again.');
$arroout["data"] = null;
}
header('Content-type: application/json');
echo CJavaScript::jsonEncode($arroout);
return;
}
}
示例2: rules
/**
* @return array validation rules for model attributes.
*/
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
$required = array();
$numerical = array();
$safe = array(); //fix a bug with setAttributes
$rules = array();
$model=$this->getFields();
foreach ($model as $field) {
$field_rule = array();
if ($field->required==ProfileField::REQUIRED_YES_NOT_SHOW_REG||$field->required==ProfileField::REQUIRED_YES_SHOW_REG)
array_push($required,$field->varname);
if ($field->field_type=='FLOAT'||$field->field_type=='INTEGER')
array_push($numerical,$field->varname);
if ($field->field_type=='VARCHAR'||$field->field_type=='TEXT') {
$field_rule = array($field->varname, 'length', 'max'=>$field->field_size, 'min' => $field->field_size_min);
if ($field->error_message) $field_rule['message'] = Users::t($field->error_message);
array_push($rules,$field_rule);
}
if ($field->other_validator) {
if (strpos($field->other_validator,'{')===0) {
$validator = (array)CJavaScript::jsonDecode($field->other_validator);
foreach ($validator as $name=>$val) {
$field_rule = array($field->varname, $name);
$field_rule = array_merge($field_rule,(array)$validator[$name]);
if ($field->error_message) $field_rule['message'] = Users::t($field->error_message);
array_push($rules,$field_rule);
}
} else {
$field_rule = array($field->varname, $field->other_validator);
if ($field->error_message) $field_rule['message'] = Users::t($field->error_message);
array_push($rules,$field_rule);
}
} elseif ($field->field_type=='DATE') {
$field_rule = array($field->varname, 'type', 'type' => 'date', 'dateFormat' => 'yyyy-mm-dd', 'allowEmpty'=>true);
if ($field->error_message) $field_rule['message'] = Users::t($field->error_message);
array_push($rules,$field_rule);
}
if ($field->match) {
$field_rule = array($field->varname, 'match', 'pattern' => $field->match);
if ($field->error_message) $field_rule['message'] = Users::t($field->error_message);
array_push($rules,$field_rule);
}
if ($field->range) {
$field_rule = array($field->varname, 'in', 'range' => self::rangeRules($field->range));
if ($field->error_message) $field_rule['message'] = Users::t($field->error_message);
array_push($rules,$field_rule);
}
array_push($safe, $field->varname); //fix a bug with setAttributes
}
array_push($rules,array(implode(',',$required), 'required'));
array_push($rules,array(implode(',',$numerical), 'numerical', 'integerOnly'=>true));
array_push($rules,array(implode(',',$safe), 'safe')); //fix a bug with setAttributes
return $rules;
}
示例3: rules
/**
* @return array validation rules for model attributes.
*/
public function rules()
{
if (!$this->_rules) {
$required = array();
$numerical = array();
$rules = array();
$model=$this->getFields();
foreach ($model as $field) {
$field_rule = array();
if ($field->required==ProfileField::REQUIRED_YES_NOT_SHOW_REG||$field->required==ProfileField::REQUIRED_YES_SHOW_REG)
array_push($required,$field->varname);
if ($field->field_type=='FLOAT'||$field->field_type=='INTEGER')
array_push($numerical,$field->varname);
if ($field->field_type=='VARCHAR'||$field->field_type=='TEXT') {
$field_rule = array($field->varname, 'length', 'max'=>$field->field_size, 'min' => $field->field_size_min);
if ($field->error_message) $field_rule['message'] = UserModule::t($field->error_message);
array_push($rules,$field_rule);
}
if ($field->other_validator) {
if (strpos($field->other_validator,'{')===0) {
$validator = (array)CJavaScript::jsonDecode($field->other_validator);
foreach ($validator as $name=>$val) {
$field_rule = array($field->varname, $name);
$field_rule = array_merge($field_rule,(array)$validator[$name]);
if ($field->error_message) $field_rule['message'] = UserModule::t($field->error_message);
array_push($rules,$field_rule);
}
} else {
$field_rule = array($field->varname, $field->other_validator);
if ($field->error_message) $field_rule['message'] = UserModule::t($field->error_message);
array_push($rules,$field_rule);
}
} elseif ($field->field_type=='DATE') {
$field_rule = array($field->varname, 'type', 'type' => 'date', 'dateFormat' => 'yyyy-mm-dd', 'allowEmpty'=>true);
if ($field->error_message) $field_rule['message'] = UserModule::t($field->error_message);
array_push($rules,$field_rule);
}
if ($field->match) {
$field_rule = array($field->varname, 'match', 'pattern' => $field->match);
if ($field->error_message) $field_rule['message'] = UserModule::t($field->error_message);
array_push($rules,$field_rule);
}
if ($field->range) {
$field_rule = array($field->varname, 'in', 'range' => self::rangeRules($field->range));
if ($field->error_message) $field_rule['message'] = UserModule::t($field->error_message);
array_push($rules,$field_rule);
}
}
array_push($rules,array(implode(',',$required), 'required'));
array_push($rules,array(implode(',',$numerical), 'numerical', 'integerOnly'=>true));
$this->_rules = $rules;
}
return $this->_rules;
}
示例4: scopes
}
public function scopes()
{
return array('forAll' => array('condition' => 'visible=' . self::VISIBLE_ALL, 'order' => 'position'), 'forUser' => array('condition' => 'visible>=' . self::VISIBLE_REGISTER_USER, 'order' => 'position'), 'forOwner' => array('condition' => 'visible>=' . self::VISIBLE_ONLY_OWNER, 'order' => 'position'), 'forRegistration' => array('condition' => 'required=' . self::REQUIRED_NO_SHOW_REG . ' OR required=' . self::REQUIRED_YES_SHOW_REG, 'order' => 'position'), 'sort' => array('order' => 'position'));
}
/**
* @param $value
* @return formated value (string)
*/
public function widgetView($model)
{
if ($this->widget && class_exists($this->widget)) {
$widgetClass = new $this->widget();
$arr = $this->widgetparams;
if ($arr) {
$newParams = $widgetClass->params;
$arr = (array) CJavaScript::jsonDecode($arr);
foreach ($arr as $p => $v) {
if (isset($newParams[$p])) {
$newParams[$p] = $v;
}
示例5: setAttributes
/**
* Extends setAttributes to handle active date fields
*
* @param $values array
* @param $safeOnly boolean
*/
public function setAttributes($values,$safeOnly=true)
{
foreach ($this->widgetAttributes() as $fieldName=>$className) {
if (isset($values[$fieldName])&&class_exists($className)) {
$class = new $className;
$arr = $this->widgetParams($fieldName);
if ($arr) {
$newParams = $class->params;
$arr = (array)CJavaScript::jsonDecode($arr);
foreach ($arr as $p=>$v) {
if (isset($newParams[$p])) $newParams[$p] = $v;
}
$class->params = $newParams;
}
if (method_exists($class,'setAttributes')) {
$values[$fieldName] = $class->setAttributes($values[$fieldName],$this,$fieldName);
}
}
}
parent::setAttributes($values,$safeOnly);
}
示例6: actionSave
/**
* Used for ajax call to save user portlets settings.
*/
public function actionSave()
{
if (isset($_POST['portlets']) && !empty($_POST['portlets'])) {
$portlets = CJavaScript::jsonDecode($_POST['portlets']);
$transaction = Yii::app()->db->beginTransaction();
try {
// Delete outdated user settings.
DashboardPortlet::model()->deleteAll('uid=:uid', array(':uid' => Yii::app()->user->id));
// Save user new settings.
$model = new DashboardPortlet();
$model->settings = serialize($portlets);
$model->save();
$transaction->commit();
echo CJavaScript::jsonEncode(array('message' => 'Save Successfully'));
} catch (Exception $e) {
$transaction->rollBack();
echo CJavaScript::jsonEncode(array('message' => 'Transaction Failed'));
}
} else {
echo CJavaScript::jsonEncode(array('message' => 'Incorrect arguments'));
}
Yii::app()->end();
}
示例7: beforeSave
public function beforeSave()
{
$values = $this->getAttributes();
foreach ($this->widgetAttributes() as $fieldName=>$className) {
if (class_exists($className)) {
$class = new $className;
$arr = $this->widgetParams($fieldName);
if ($arr) {
$newParams = $class->params;
$arr = (array)CJavaScript::jsonDecode($arr);
foreach ($arr as $p=>$v) {
if (isset($newParams[$p])) $newParams[$p] = $v;
}
$class->params = $newParams;
}
if (method_exists($class,'save')) {
$value = $class->save($values[$fieldName],$this,$fieldName);
$this->setAttribute($fieldName, $value);
}
}
}
return parent::beforeSave();
}
示例8: actionBuscaDataIndex
public function actionBuscaDataIndex()
{
if (Yii::app()->request->isAjaxRequest) {
$arrayData = array();
$obj = new NubeFactura();
$contBuscar = isset($_POST['CONT_BUSCAR']) ? CJavaScript::jsonDecode($_POST['CONT_BUSCAR']) : array();
$arrayData = $obj->mostrarDocumentos($contBuscar);
$this->renderPartial('_indexGrid', array('model' => $arrayData), false, true);
return;
}
}
示例9: rules
/**
* @return array validation rules for model attributes.
*/
public function rules()
{
if (!$this->_rules) {
$required = array();
$numerical = array();
$float = array();
$decimal = array();
$rules = array();
array_push($numerical, 'mailing_for_executors');
array_push($numerical, 'general_mailing');
$model = $this->getFields();
foreach ($model as $field) {
$field_rule = array();
if ($field->required == ProfileField::REQUIRED_YES_NOT_SHOW_REG || $field->required == ProfileField::REQUIRED_YES_SHOW_REG) {
array_push($required, $field->varname);
}
if ($field->field_type == 'FLOAT') {
array_push($float, $field->varname);
}
if ($field->field_type == 'DECIMAL') {
array_push($decimal, $field->varname);
}
if ($field->field_type == 'INTEGER') {
array_push($numerical, $field->varname);
}
if ($field->field_type == 'VARCHAR' || $field->field_type == 'TEXT' || $field->field_type == 'LIST') {
$field_rule = array($field->varname, 'length', 'max' => $field->field_type == 'TEXT' || $field->field_type == 'LIST' ? 65535 : $field->field_size, 'min' => $field->field_size_min);
if ($field->error_message) {
$field_rule['message'] = UserModule::t($field->error_message);
}
array_push($rules, $field_rule);
}
if ($field->other_validator) {
if (strpos($field->other_validator, '{') === 0) {
$validator = (array) CJavaScript::jsonDecode($field->other_validator);
foreach ($validator as $name => $val) {
$field_rule = array($field->varname, $name);
$field_rule = array_merge($field_rule, (array) $validator[$name]);
if ($field->error_message) {
$field_rule['message'] = UserModule::t($field->error_message);
}
array_push($rules, $field_rule);
}
} else {
$field_rule = array($field->varname, $field->other_validator);
if ($field->error_message) {
$field_rule['message'] = UserModule::t($field->error_message);
}
array_push($rules, $field_rule);
}
} elseif ($field->field_type == 'DATE') {
$field_rule = array($field->varname, 'type', 'type' => 'date', 'dateFormat' => 'yyyy-mm-dd', 'allowEmpty' => true);
if ($field->error_message) {
$field_rule['message'] = UserModule::t($field->error_message);
}
array_push($rules, $field_rule);
}
if ($field->match) {
$field_rule = array($field->varname, 'match', 'pattern' => $field->match);
if ($field->error_message) {
$field_rule['message'] = UserModule::t($field->error_message);
}
array_push($rules, $field_rule);
}
if ($field->range) {
$field_rule = array($field->varname, 'in', 'range' => self::rangeRules($field->range));
if ($field->error_message) {
$field_rule['message'] = UserModule::t($field->error_message);
}
array_push($rules, $field_rule);
}
}
array_push($rules, array(implode(',', $required), 'required'));
array_push($rules, array(implode(',', $numerical), 'numerical', 'integerOnly' => true));
array_push($rules, array(implode(',', $float), 'type', 'type' => 'float'));
array_push($rules, array(implode(',', $decimal), 'match', 'pattern' => '/^\\s*[-+]?[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?\\s*$/'));
array_push($rules, array('hours, minutes', 'safe'));
$this->_rules = $rules;
}
return $this->_rules;
}
示例10: actionIndex
/**
* Lists all models.
*/
public function actionIndex()
{
$modelo = new NubeNotaCredito();
$tipDoc = new VSDirectorio();
$aproba = new VSacceso();
$contBuscar = array();
if (Yii::app()->request->isAjaxRequest) {
//$contBuscar = isset($_POST['CONT_BUSCAR']) ? CJavaScript::jsonDecode($_POST['CONT_BUSCAR']) : array();
//echo CJSON::encode($modelo->mostrarDocumentos($contBuscar));
$arrayData = array();
$contBuscar = isset($_POST['CONT_BUSCAR']) ? CJavaScript::jsonDecode($_POST['CONT_BUSCAR']) : array();
$contBuscar[0]['PAGE'] = isset($_GET['page']) ? $_GET['page'] : 0;
$arrayData = $modelo->mostrarDocumentos($contBuscar);
$this->renderPartial('_indexGrid', array('model' => $arrayData), false, true);
return;
}
$this->titleWindows = Yii::t('DOCUMENTOS', 'Credit Note');
$this->render('index', array('model' => $modelo->mostrarDocumentos($contBuscar), 'tipoDoc' => $tipDoc->recuperarTipoDocumentos(), 'tipoApr' => $aproba->tipoAprobacion()));
}
示例11: rules
/**
* @return array validation rules for model attributes.
*/
public function rules()
{
if (!self::$_rules) {
$required = array();
$numerical = array();
$float = array();
$decimal = array();
$safe = array();
$rules = array();
$model = self::getFields();
foreach ($model as $field) {
$field_rule = array();
array_push($safe, $field->varname);
if ($field->required == BaseCccfCustomField::REQUIRED_YES) {
array_push($required, $field->varname);
}
if ($field->field_type == 'FLOAT') {
array_push($float, $field->varname);
}
if ($field->field_type == 'DECIMAL') {
array_push($decimal, $field->varname);
}
if ($field->field_type == 'INTEGER') {
array_push($numerical, $field->varname);
}
if ($field->field_type == 'VARCHAR' || $field->field_type == 'TEXT') {
$field_rule = array($field->varname, 'length', 'max' => $field->field_size, 'min' => $field->field_size_min);
if ($field->error_message) {
$field_rule['message'] = UserModule::t($field->error_message);
}
array_push($rules, $field_rule);
}
if ($field->other_validator) {
if (strpos($field->other_validator, '{') === 0) {
$validator = (array) CJavaScript::jsonDecode($field->other_validator);
foreach ($validator as $name => $val) {
$field_rule = array($field->varname, $name);
$field_rule = array_merge($field_rule, (array) $validator[$name]);
if ($field->error_message) {
$field_rule['message'] = UserModule::t($field->error_message);
}
array_push($rules, $field_rule);
}
} else {
$field_rule = array($field->varname, $field->other_validator);
if ($field->error_message) {
$field_rule['message'] = UserModule::t($field->error_message);
}
array_push($rules, $field_rule);
}
} elseif ($field->field_type == 'DATE') {
if ($field->required) {
$field_rule = array($field->varname, 'date', 'format' => array('yyyy-mm-dd'));
} else {
$field_rule = array($field->varname, 'date', 'format' => array('yyyy-mm-dd', '0000-00-00'), 'allowEmpty' => true);
}
if ($field->error_message) {
$field_rule['message'] = UserModule::t($field->error_message);
}
array_push($rules, $field_rule);
}
if ($field->match) {
$field_rule = array($field->varname, 'match', 'pattern' => $field->match);
if ($field->error_message) {
$field_rule['message'] = UserModule::t($field->error_message);
}
array_push($rules, $field_rule);
}
if ($field->range) {
$field_rule = array($field->varname, 'in', 'range' => self::rangeRules($field->range));
if ($field->error_message) {
$field_rule['message'] = UserModule::t($field->error_message);
}
array_push($rules, $field_rule);
}
}
array_push($rules, array(implode(',', $required), 'required'));
array_push($rules, array(implode(',', $numerical), 'numerical', 'integerOnly' => true));
array_push($rules, array(implode(',', $float), 'type', 'type' => 'float'));
array_push($rules, array(implode(',', $decimal), 'match', 'pattern' => '/^\\s*[-+]?[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?\\s*$/'));
array_push($rules, array(implode(',', $safe), 'safe'));
self::$_rules = $rules;
}
return self::$_rules;
}
示例12: performAjaxValidation
/**
* Performs the AJAX validation.
* @param CModel the model to be validated
*/
protected function performAjaxValidation($model, $ProductValue, $newPhoto)
{
if (isset($_POST['ajax']) && $_POST['ajax'] === 'product-form') {
$rez = array();
$rez = array_merge($rez, CJavaScript::jsonDecode(CActiveForm::validate($model)));
$rez = array_merge($rez, CJavaScript::jsonDecode(CActiveForm::validate($ProductValue)));
$rez = array_merge($rez, CJavaScript::jsonDecode(CActiveForm::validate($newPhoto)));
echo CJavaScript::jsonEncode($rez);
Yii::app()->end();
}
}
示例13: rules
public function rules()
{
if (!self::$_rules) {
$required = array();
$numerical = array();
$float = array();
$decimal = array();
$rules = array();
$test = array();
$model = self::getFields();
foreach ($model as $field) {
$field_rule = array();
if ($field->REQUIRED == FormField::REQUIRED_YES) {
array_push($required, $field->VARNAME);
}
if ($field->FIELD_TYPE == 'FLOAT') {
array_push($float, $field->VARNAME);
}
if ($field->FIELD_TYPE == 'DECIMAL') {
array_push($decimal, $field->VARNAME);
}
if ($field->FIELD_TYPE == 'INTEGER') {
array_push($numerical, $field->VARNAME);
}
if ($field->FIELD_TYPE == 'VARCHAR' || $field->FIELD_TYPE == 'TEXT') {
$field_rule = array($field->VARNAME, 'length', 'max' => $field->FIELD_SIZE, 'min' => $field->FIELD_SIZE_MIN);
if ($field->ERROR_MESSAGE) {
$field_rule['message'] = $field->ERROR_MESSAGE;
}
array_push($rules, $field_rule);
}
if ($field->OTHER_VALIDATOR) {
if (strpos($field->OTHER_VALIDATOR, '{') === 0) {
$validator = (array) CJavaScript::jsonDecode($field->OTHER_VALIDATOR);
foreach ($validator as $name => $val) {
$field_rule = array($field->VARNAME, $name);
$field_rule = array_merge($field_rule, (array) $validator[$name]);
if ($field->error_message) {
$field_rule['message'] = $field->ERROR_MESSAGE;
}
array_push($rules, $field_rule);
}
} else {
$field_rule = array($field->VARNAME, $field->OTHER_VALIDATOR);
if ($field->ERROR_MESSAGE) {
$field_rule['message'] = $field->ERROR_MESSAGE;
}
array_push($rules, $field_rule);
}
} elseif ($field->FIELD_TYPE == 'DATE') {
if ($field->REQUIRED) {
$field_rule = array($field->VARNAME, 'date', 'format' => array('yyyy-mm-dd'));
} else {
$field_rule = array($field->VARNAME, 'date', 'format' => array('yyyy-mm-dd', '0000-00-00'), 'allowEmpty' => true);
}
if ($field->ERROR_MESSAGE) {
$field_rule['message'] = $field->ERROR_MESSAGE;
}
array_push($rules, $field_rule);
}
if ($field->MATCH) {
$field_rule = array($field->VARNAME, 'match', 'pattern' => $field->MATCH);
if ($field->ERROR_MESSAGE) {
$field_rule['message'] = $field->ERROR_MESSAGE;
}
array_push($rules, $field_rule);
}
if ($field->RANGE) {
$field_rule = array($field->VARNAME, 'in', 'range' => self::rangeRules($field->RANGE));
if ($field->ERROR_MESSAGE) {
$field_rule['message'] = $field->ERROR_MESSAGE;
}
array_push($rules, $field_rule);
}
}
//foreach $field
array_push($rules, array(implode(',', $required), 'required'));
array_push($rules, array(implode(',', $numerical), 'numerical', 'integerOnly' => true));
array_push($rules, array(implode(',', $float), 'type', 'type' => 'float'));
array_push($rules, array(implode(',', $decimal), 'match', 'pattern' => '/^\\s*[-+]?[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?\\s*$/'));
array_push($rules, array('FORM_ID', 'default', 'value' => Yii::app()->params['form-id'], 'setOnEmpty' => false, 'on' => 'insert'));
array_push($rules, array('CREATED_BY, LAST_MODIFIED_BY', 'length', 'max' => 255));
array_push($rules, array('CREATED_DATE, LAST_MODIFIED_DATE', 'safe'));
// The following rule is used by search().
// Please remove those attributes that should not be searched.
array_push($rules, array('ID, FORM_ID, CREATED_BY, LAST_MODIFIED_BY, CREATED_DATE, LAST_MODIFIED_DATE', 'safe', 'on' => 'search'));
//Tracking
array_push($rules, array('LAST_MODIFIED_DATE', 'default', 'value' => new CDbExpression('NOW()'), 'setOnEmpty' => false, 'on' => 'update'));
array_push($rules, array('CREATED_DATE', 'default', 'value' => new CDbExpression('NOW()'), 'setOnEmpty' => false, 'on' => 'insert'));
array_push($rules, array('LAST_MODIFIED_BY', 'default', 'value' => Yii::app()->user->id, 'setOnEmpty' => false, 'on' => 'update'));
array_push($rules, array('CREATED_BY', 'default', 'value' => Yii::app()->user->id, 'setOnEmpty' => false, 'on' => 'insert'));
self::$_rules = $rules;
}
return self::$_rules;
}
示例14: rules
/**
* @return array validation rules for model attributes.
*/
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
$required = array();
$numerical = array();
$rules = array();
$model = $this->_getModel();
foreach ($model as $field) {
$field_rule = array();
if ($field->required == CDynamicFieldModel::REQUIRED_YES) {
array_push($required, $field->varname);
}
if ($field->field_type == 'FLOAT' || $field->field_type == 'INTEGER') {
array_push($numerical, $field->varname);
}
if ($field->field_type == 'VARCHAR' || $field->field_type == 'TEXT') {
$field_rule = array($field->varname, 'length', 'max' => $field->field_size, 'min' => $field->field_size_min);
if ($field->error_message) {
$field_rule['message'] = CartModule::t($field->error_message, $this->parentName());
}
array_push($rules, $field_rule);
}
if ($field->other_validator) {
if (strpos($field->other_validator, '{') === 0) {
$validator = (array) CJavaScript::jsonDecode($field->other_validator);
$field_rule = array($field->varname, key($validator));
$field_rule = array_merge($field_rule, (array) $validator[key($validator)]);
} else {
$field_rule = array($field->varname, $field->other_validator);
}
if ($field->error_message) {
$field_rule['message'] = CartModule::t($field->error_message, $this->parentName());
}
array_push($rules, $field_rule);
} elseif ($field->field_type == 'DATE') {
$field_rule = array($field->varname, 'type', 'type' => 'date', 'dateFormat' => 'yyyy-mm-dd', 'allowEmpty' => true);
if ($field->error_message) {
$field_rule['message'] = CartModule::t($field->error_message, $this->parentName());
}
array_push($rules, $field_rule);
}
if ($field->match) {
$field_rule = array($field->varname, 'match', 'pattern' => $field->match);
if ($field->error_message) {
$field_rule['message'] = CartModule::t($field->error_message, $this->parentName());
}
array_push($rules, $field_rule);
}
if ($field->range) {
$field_rule = array($field->varname, 'in', 'range' => $this->rangeRules($field->range));
if ($field->error_message) {
$field_rule['message'] = CartModule::t($field->error_message, $this->parentName());
}
array_push($rules, $field_rule);
}
}
array_push($rules, array(implode(',', $required), 'required'));
array_push($rules, array(implode(',', $numerical), 'numerical', 'integerOnly' => true));
return $rules;
}