问答 / 0 / 1 / 创建于 4年前 / 更新于 4年前
想做成:第 几 行商品分类不能为空,这样的错误提示。
社区里的各位朋友有知道怎么做的?
public function rules() { return [ 'product_data.*.category_name' => [ function ($attribute, $value, $fail) { preg_match('/product_data\.(\d+)\.category_name/', $attribute, $m); $index = $m[1]; if (empty($value)) { return $fail('第' . $index+1 . '行商品分类不能为空。'); } }, ] ] }
我要举报该,理由是: