laravel 数组的旧输入?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/42050732/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 15:16:26  来源:igfitidea点击:

Old input for array?

laravellaravel-5laravel-5.2

提问by None

I have foreachand inside foreachi have input like this:

我在foreach里面foreach有这样的输入:

 <input type="text" id="text-title" name="article_title[{{$language->code}}]" value="{{ old('article_title[$language->code]') }}" class="form_input"  />

Im trying to add old input like this but its not working. Any suggestion how can i use old for array?

我试图添加这样的旧输入,但它不起作用。任何建议我如何使用旧数组?

Also i tried this but also not working:

我也试过这个,但也不起作用:

  <input type="text" id="text-title" name="article_title[{{$language->code}}]" value="{{ old('article_title.0') }}" class="form_input"  />

I have validation only for first iteration if that means anything for you.

如果这对您有任何意义,我只对第一次迭代进行验证。

回答by Ohgodwhy

You should be able to access the index off of your language code:

您应该能够访问您的语言代码的索引:

value="{{ old('article_title.'.$language_code) }}"