验证返回“未定义索引”,因为上下文数据丢失了?

时间:2017-11-18 00:31:29

标签: cakephp-3.0

我有以下代码,它一直给我payment_method_id“Undefined index”错误,所以我检查了debug.log文件,它显示

2017-11-18 00:27:39 Debug: 7
2017-11-18 00:27:40 Debug: 

似乎验证方法被调用了2次,并且第一次$ context ['data'] [payment_method_id]存在,但在那之后,第二次,它不再存在?谁知道如何解决这个问题?感谢

$validator->notEmpty('cc_expires', __('This field is required'),
                function ($context) {

                    Log::write('debug', $context['data'][payment_method_id]);
                    if ($context ['data'] ['payment_method_id'] == 1 )
                    {
                        return true;
                    }}

                );

0 个答案:

没有答案
相关问题