save() 时报 500 错误 [ 2.0 版本 ]
在一个ajax发送请求和保存数据的时候报500错误
代码:
$res = new Apptxt();
$res->datetime = time();
$res->appid = 7;
$res->content = "123456";
$res->creater = 7;
$res->isdel = 0;
$res->save();
错误代码
Exception 'ReflectionException' with message 'Class numerical does not exist'
in C:\xampp\htdocs\coupon\vendor\yiisoft\yii2\di\Container.php:415
Stack trace:
#0 C:\xampp\htdocs\coupon\vendor\yiisoft\yii2\di\Container.php(415): ReflectionClass->__construct('numerical')
#1 C:\xampp\htdocs\coupon\vendor\yiisoft\yii2\di\Container.php(358): yii\di\Container->getDependencies('numerical')
#2 C:\xampp\htdocs\coupon\vendor\yiisoft\yii2\di\Container.php(151): yii\di\Container->build('numerical', Array, Array)
#3 C:\xampp\htdocs\coupon\vendor\yiisoft\yii2\BaseYii.php(344): yii\di\Container->get('numerical', Array, Array)
#4 C:\xampp\htdocs\coupon\vendor\yiisoft\yii2\validators\Validator.php(206): yii\BaseYii::createObject(Array)
#5 C:\xampp\htdocs\coupon\vendor\yiisoft\yii2\base\Model.php(440): yii\validators\Validator::createValidator('numerical', Object(app\models\Apptxt), Array, Array)
#6 C:\xampp\htdocs\coupon\vendor\yiisoft\yii2\base\Model.php(404): yii\base\Model->createValidators()
#7 C:\xampp\htdocs\coupon\vendor\yiisoft\yii2\base\Model.php(184): yii\base\Model->getValidators()
#8 C:\xampp\htdocs\coupon\vendor\yiisoft\yii2\base\Model.php(340): yii\base\Model->scenarios()
#9 C:\xampp\htdocs\coupon\vendor\yiisoft\yii2\db\ActiveRecord.php(416): yii\base\Model->validate(NULL)
#10 C:\xampp\htdocs\coupon\vendor\yiisoft\yii2\db\BaseActiveRecord.php(589): yii\db\ActiveRecord->insert(true, NULL)
#11 C:\xampp\htdocs\coupon\controllers\NrkController.php(219): yii\db\BaseActiveRecord->save()
#12 [internal function]: app\controllers\NrkController->actionEdittxtmsg('0')
#13 C:\xampp\htdocs\coupon\vendor\yiisoft\yii2\base\InlineAction.php(55): call_user_func_array(Array, Array)
#14 C:\xampp\htdocs\coupon\vendor\yiisoft\yii2\base\Controller.php(151): yii\base\InlineAction->runWithParams(Array)
#15 C:\xampp\htdocs\coupon\vendor\yiisoft\yii2\base\Module.php(455): yii\base\Controller->runAction('edittxtmsg', Array)
#16 C:\xampp\htdocs\coupon\vendor\yiisoft\yii2\web\Application.php(84): yii\base\Module->runAction('nrk/edittxtmsg', Array)
#17 C:\xampp\htdocs\coupon\vendor\yiisoft\yii2\base\Application.php(375): yii\web\Application->handleRequest(Object(yii\web\Request))
#18 C:\xampp\htdocs\coupon\web\index.php(12): yii\base\Application->run()
#19 {main}
可能是因为什么,求大腿指教
最佳答案
-
chocoboxxf 发布于 2015-08-12 11:10 举报
是不是在Apptxt类里的rules里面给哪个属性加了个数字验证,把number打成了numerical?yii2里面没有内置叫numerical的验证类
共 1 条回复
我是兴高采烈 湖北武汉
注册时间:2015-06-26
最后登录:2015-10-08
在线时长:11小时57分
最后登录:2015-10-08
在线时长:11小时57分
- 粉丝5
- 金钱1049
- 威望0
- 积分1159