Conditional Validation In Yii2.0 fail

无人久伴 提交于 2019-12-14 03:26:29

问题


I'm setting up the required rule based on condition but looks like it abuse the condition. what I am I went wrong ???

['objective_id','required','when'=>function($model){ return $model->subcategory_id == 3; }],

回答1:


I figure out my problem, the code is right but I forgot that I'm working with ActiveRecord. I solved it by set up the field "objective_id" to null in a database table



来源:https://stackoverflow.com/questions/54228799/conditional-validation-in-yii2-0-fail

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!