<i id='aWdnL'><tr id='aWdnL'><dt id='aWdnL'><q id='aWdnL'><span id='aWdnL'><b id='aWdnL'><form id='aWdnL'><ins id='aWdnL'></ins><ul id='aWdnL'></ul><sub id='aWdnL'></sub></form><legend id='aWdnL'></legend><bdo id='aWdnL'><pre id='aWdnL'><center id='aWdnL'></center></pre></bdo></b><th id='aWdnL'></th></span></q></dt></tr></i><div id='aWdnL'><tfoot id='aWdnL'></tfoot><dl id='aWdnL'><fieldset id='aWdnL'></fieldset></dl></div>

    • <bdo id='aWdnL'></bdo><ul id='aWdnL'></ul>
    1. <legend id='aWdnL'><style id='aWdnL'><dir id='aWdnL'><q id='aWdnL'></q></dir></style></legend>
    2. <tfoot id='aWdnL'></tfoot>
    3. <small id='aWdnL'></small><noframes id='aWdnL'>

      具有多个值的 required_if laravel

      Required_if laravel with multiple value(具有多个值的 required_if laravel)
      • <legend id='HH2xn'><style id='HH2xn'><dir id='HH2xn'><q id='HH2xn'></q></dir></style></legend>

          <bdo id='HH2xn'></bdo><ul id='HH2xn'></ul>
        • <tfoot id='HH2xn'></tfoot>

              <small id='HH2xn'></small><noframes id='HH2xn'>

              <i id='HH2xn'><tr id='HH2xn'><dt id='HH2xn'><q id='HH2xn'><span id='HH2xn'><b id='HH2xn'><form id='HH2xn'><ins id='HH2xn'></ins><ul id='HH2xn'></ul><sub id='HH2xn'></sub></form><legend id='HH2xn'></legend><bdo id='HH2xn'><pre id='HH2xn'><center id='HH2xn'></center></pre></bdo></b><th id='HH2xn'></th></span></q></dt></tr></i><div id='HH2xn'><tfoot id='HH2xn'></tfoot><dl id='HH2xn'><fieldset id='HH2xn'></fieldset></dl></div>
                  <tbody id='HH2xn'></tbody>
                本文介绍了具有多个值的 required_if laravel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我有一个这样的下拉菜单:

                I have a dropdown menu like this:

                <select name="selection">
                   <option value="1">Option 1</option>
                   <option value="2">Option 2</option>
                   <option value="3">Option 3</option>
                </select>
                <input type="text" name="stext">
                

                我想要在 Laravel 中的以下内容:

                I want the following in laravel:

                public static myfunction(){
                   $input = Input::only('selection','stext');
                   $rule = array(
                      'selection' => 'required',
                      'stext' => 'required_if:selection,2,3',
                   );
                   $validate = Validator::make($input,$rule);
                }
                

                但是如果我选择选项 1,stext 仍然是必需的.为什么?我该如何解决?

                But if I select option 1, stext is still required. Why? How can I fix it?

                推荐答案

                正如 LePhleg answer 所指出的,此验证有一个最好的语法:

                As pointed out by LePhleg answer, there is a nicest syntax for this validation:

                $rule = array(
                  'selection' => 'required',
                  'stext' => 'required_if:selection,2,3,
                );
                

                下面的旧答案:

                我认为 require_if 验证每次只接受一个值.尝试更改您的验证代码如下:

                I think that the require_if validation accept only one value per time. Try to change your validation code as below:

                $rule = array(
                  'selection' => 'required',
                  'stext' => 'required_if:selection,2|required_if:selection,3',
                );
                

                检查 LePhleg 的答案,更干净.在回答不可能的时候,只检查问题,他正在使用相同的方法但没有奏效.

                Check LePhleg answer, is more cleaner. At the time of the answer that was not possible, just check the question, he was using the same method but not worked.

                这篇关于具有多个值的 required_if laravel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                Appending GET parameters to URL from lt;formgt; action(将 GET 参数附加到来自 lt;formgt; 的 URL行动)
                Forcing quot;Save Asquot; dialog via jQuery GET(强制“另存为通过 jQuery GET 对话框)
                PHP - get certain word from string(PHP - 从字符串中获取某个单词)
                How to debug a get request in php using curl(如何使用 curl 在 php 中调试 get 请求)
                get a # from a url in php(从 php 中的 url 获取 #)
                PHP - include() file not working when variables are put in url?(PHP - 将变量放入 url 时,include() 文件不起作用?)
                <tfoot id='MKFcJ'></tfoot>

                <small id='MKFcJ'></small><noframes id='MKFcJ'>

                  <tbody id='MKFcJ'></tbody>
                      <bdo id='MKFcJ'></bdo><ul id='MKFcJ'></ul>
                        <i id='MKFcJ'><tr id='MKFcJ'><dt id='MKFcJ'><q id='MKFcJ'><span id='MKFcJ'><b id='MKFcJ'><form id='MKFcJ'><ins id='MKFcJ'></ins><ul id='MKFcJ'></ul><sub id='MKFcJ'></sub></form><legend id='MKFcJ'></legend><bdo id='MKFcJ'><pre id='MKFcJ'><center id='MKFcJ'></center></pre></bdo></b><th id='MKFcJ'></th></span></q></dt></tr></i><div id='MKFcJ'><tfoot id='MKFcJ'></tfoot><dl id='MKFcJ'><fieldset id='MKFcJ'></fieldset></dl></div>
                      1. <legend id='MKFcJ'><style id='MKFcJ'><dir id='MKFcJ'><q id='MKFcJ'></q></dir></style></legend>