Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Old input for array?

I have foreach and inside foreach i have input like this:

 <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.

like image 837
None Avatar asked Feb 05 '17 10:02

None


2 Answers

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

value="{{ old('article_title.'.$language_code) }}"
like image 181
Ohgodwhy Avatar answered Nov 14 '22 02:11

Ohgodwhy


you can use the old to return old value as an array

# old('article_title') => array

value="{{ old('article_title')[$language_code] ?? "" }}"

like image 2
keroles Monsef Avatar answered Nov 14 '22 03:11

keroles Monsef