Laravel 5.6 required_if复选框已选中

时间:2019-04-02 10:59:16

标签: laravel forms validation

在我的表单中,我使用带有名为“ my-event”的验证组的规则来验证字段。我的规则之一是,如果选中了一个名为“其他”的复选框,则需要填写文本字段“其他”。总共有8个复选框。

输入的名称称为event-type,并且存在一个值为other的复选框。

我为此验证编写的规则是:

"my-event.event-type": "required",

"my-event.event-type-other":  "required_if:my-event.event-type,other",

但是,当我选中“其他”复选框并且不填写文本字段时,我没有任何验证问题。我已经转储了请求,可以看到选中了“其他”复选框:

"event-type" => array:6 [▼
          0 => "casual"
          1 => "free"
          2 => "other"
        ]

在尝试解决此问题时,我有什么要重点注意的?

0 个答案:

没有答案