Question

I have 2 email fields and I am using

{{ Form::text('email[]', Input::old('email'),array('class' => 'large-2', 'placeholder' => 'email address','id'=>'email')) }}`

if I use [] to get multiple values for same variable, it is giving error in view page if posted back some data. for example if some fields are mandatory and if user fail to fill those, page will be redirected to same view page from where it was launched.

In such cases it is showing error.

How to fix this issue?

Was it helpful?

Solution

One text field can contain only one data. So, you need another text field to achieve that. if you don't want to show the multiple emails, you can use hidden fields.

{{ Form::hidden('email[]', Input::old('email1'))
{{ Form::hidden('email[]', Input::old('email2'))

Or you can use select. Laravel allow array data if use select field.

For example:

{{  Form::select('size', array('L' => 'Large', 'S' => 'Small')) }}

http://laravel.com/docs/html#drop-down-lists

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top