title: Laravel 5 validation error
body: <p>I have the following view:</p>
  
  <pre><code>@extends('layouts.admin')
  
  @section('pagetitle')
      Edit Settings
  @stop
  
  @section('content')
  
  {!! $message or '' !!}
  
  @if (count($errors) &gt; 0)
      &lt;div class="alert alert-danger"&gt;
          &lt;strong&gt;Whoops!&lt;/strong&gt; There were some problems with your input.&lt;br&gt;&lt;br&gt;
          &lt;ul&gt;
              @foreach ($errors-&gt;all() as $error)
                  &lt;li&gt;{{ $error }}&lt;/li&gt;
              @endforeach
          &lt;/ul&gt;
      &lt;/div&gt;
  @endif
  
  &lt;div class="portlet light bordered"&gt;
  
      &lt;div class="portlet-title"&gt;
          &lt;div class="caption font-red-sunglo"&gt;
              &lt;i class="fa fa-tag font-red-sunglo"&gt;&lt;/i&gt;
              &lt;span class="caption-subject bold uppercase"&gt;Discounts&lt;/span&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  
      &lt;div class="row"&gt;
  
          &lt;div class="col-xs-12"&gt;
  
              &lt;form role="form" method="POST" action="{!! URL::to('admin/discounts/update') !!}"&gt;
                  &lt;input type="hidden" name="_token" value="{{ csrf_token() }}"&gt;
  
                  &lt;table class="table table-bordered table-striped table-hover"&gt;
                      &lt;thead&gt;
                          &lt;tr&gt;
                              &lt;th width="30%"&gt;Minimum Credits&lt;/th&gt;
                              &lt;th width="30%"&gt;Maximum Credits&lt;/th&gt;
                              &lt;th width="30%"&gt;Discount %&lt;/th&gt;
                              &lt;th width="100"&gt;&lt;/th&gt;
                              &lt;th width="100"&gt;&lt;/th&gt;
                          &lt;/tr&gt;
                      &lt;/thead&gt;
                      &lt;tbody&gt;
                          @if(count($discounts)==0)
                              &lt;tr&gt;
                                  &lt;td&gt;
                                      {!! Form::text('min_credits[]', null, array('class' =&gt; 'form-control')) !!}
                                  &lt;/td&gt;
                                  &lt;td&gt;
                                      {!! Form::text('max_credits[]', null, array('class' =&gt; 'form-control')) !!}
                                  &lt;/td&gt;
                                  &lt;td&gt;
                                      &lt;div class="input-group"&gt;
                                          {!! Form::text('discount_percent[]', null, array('class' =&gt; 'form-control')) !!}
                                          &lt;span class="input-group-addon"&gt;%&lt;/span&gt;
                                      &lt;/div&gt;
                                  &lt;/td&gt;
                                  &lt;td&gt;&lt;button type="button" class="btn red delete"&gt;&lt;i class="fa fa-trash"&gt;&lt;/i&gt; Delete&lt;/td&gt;
                                  &lt;td&gt;&lt;button type="button" class="btn green newrow"&gt;&lt;i class="fa fa-plus"&gt;&lt;/i&gt; New Row&lt;/button&gt;&lt;/td&gt;
                              &lt;/tr&gt;
                          @else
                              @foreach($discounts as $discount)
                                  &lt;tr&gt;
                                      &lt;td&gt;
                                          {!! Form::text('min_credits[]', $discount-&gt;min_credits, array('class' =&gt; 'form-control')) !!}
                                      &lt;/td&gt;
                                      &lt;td&gt;
                                          {!! Form::text('max_credits[]', $discount-&gt;max_credits, array('class' =&gt; 'form-control')) !!}
                                      &lt;/td&gt;
                                      &lt;td&gt;
                                          &lt;div class="input-group"&gt;
                                              {!! Form::text('discount_percent[]', $discount-&gt;discount_percent, array('class' =&gt; 'form-control')) !!}
                                              &lt;span class="input-group-addon"&gt;%&lt;/span&gt;
                                          &lt;/div&gt;
                                      &lt;/td&gt;
                                      &lt;td&gt;&lt;button type="button" class="btn red delete"&gt;&lt;i class="fa fa-trash"&gt;&lt;/i&gt; Delete&lt;/td&gt;
                                      &lt;td&gt;&lt;button type="button" class="btn green newrow"&gt;&lt;i class="fa fa-plus"&gt;&lt;/i&gt; New Row&lt;/button&gt;&lt;/td&gt;
                                  &lt;/tr&gt;
                              @endforeach
                          @endif
                      &lt;/tbody&gt;
                  &lt;/table&gt;
  
                  &lt;div class="row mtop20"&gt;
                      &lt;div class="col-xs-12"&gt;
                          {!! Form::submit('Update', array('class' =&gt; 'btn btn-primary')) !!}
                      &lt;/div&gt;
                  &lt;/div&gt;
              &lt;/form&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  
  @stop
  
  @section('scripts')
      &lt;script type="text/javascript"&gt;
          $(document).ready(function() {
  
              $('.delete').click(function() {
                  if(confirm("Are you sure you want to delete this row?")){
                      $(this).closest('tr').remove();
                  }
              });
  
              $('.newrow').click(function() {
                  html = '&lt;tr&gt;\
                              &lt;td&gt;\
                                  {!! Form::text('min_credits[]', "", array('class' =&gt; 'form-control')) !!}\
                              &lt;/td&gt;\
                              &lt;td&gt;\
                                  {!! Form::text('max_credits[]', "", array('class' =&gt; 'form-control')) !!}\
                              &lt;/td&gt;\
                              &lt;td&gt;\
                                  &lt;div class="input-group"&gt;\
                                      {!! Form::text('discount_percent[]', "", array('class' =&gt; 'form-control')) !!}\
                                      &lt;span class="input-group-addon"&gt;%&lt;/span&gt;\
                                  &lt;/div&gt;\
                              &lt;/td&gt;\
                              &lt;td&gt;&lt;button type="button" class="btn red delete"&gt;&lt;i class="fa fa-trash"&gt;&lt;/i&gt; Delete&lt;/td&gt;\
                              &lt;td&gt;&lt;button type="button" class="btn green newrow"&gt;&lt;i class="fa fa-plus"&gt;&lt;/i&gt; New Row&lt;/button&gt;&lt;/td&gt;\
                          &lt;/tr&gt;';
                  $(this).closest('tr').after(html);
              });
  
          });
      &lt;/script&gt;
  @stop
  </code></pre>
  
  <p>The following request:</p>
  
  <pre><code>&lt;?php namespace App\Http\Requests;
  
  use App\Http\Requests\Request;
  use Validator;
  use Session;
  use Auth;
  
  class DiscountsEditRequest extends Request {
  
      /**
       * Determine if the user is authorized to make this request.
       *
       * @return bool
       */
      public function authorize()
      {
          return true;
      }
  
      /**
       * Set up the validation rules
       */
      public function rules()
      {
          $rules = [
              'min_credits' =&gt; 'array',
              'max_credits' =&gt; 'array',
              'discount_percent' =&gt; 'array'
          ];
  
          $row_count = count($this-&gt;min_credits);
          for($i=0; $i&lt;$row_count; $i++) {
              $rules['min_credits.'.$i] = 'required|integer';
              $rules['max_credits.'.$i] = 'integer';
              $rules['discount_percent.'.$i] = 'required|integer';
          }
  
          return $rules;
      }
  
      public function messages()
      {
          $messages = [
              'min_credits.array' =&gt; 'The minimum credits field must be an array.',
              'max_credits.array' =&gt; 'The maximum credits field must be an array.',
              'discount_percent.array' =&gt; 'The discount percent field must be an array.',
              'discount_percent.required' =&gt; 'The discount field is required.'
          ];
  
          $row_count = count($this-&gt;min_credits);
          for($i=0; $i&lt;$row_count; $i++) {
              $messages['min_credits.'.$i.'required'] = 'The minimum credits field is required.';
              $messages['min_credits.'.$i.'integer'] = 'The minimum credits field must contain an integer.';
              $messages['max_credits.'.$i.'integer'] = 'The maximum credits field must contain an integer.';
              $messages['discount_percent.'.$i.'required'] = 'The discount field is required.';
              $messages['discount_percent.'.$i.'integer'] = 'The discount field must contain an integer.';
          }
  
          return $messages;
      }
  
  }
  </code></pre>
  
  <p>The following controller:</p>
  
  <pre><code>&lt;?php namespace App\Http\Controllers\Admin;
  
  use App\Http\Requests;
  use App\Http\Controllers\Controller;
  use App\Http\Requests\DiscountsEditRequest;
  
  use Illuminate\Http\Request;
  use View;
  use Session;
  use Input;
  use Response;
  use Auth;
  use App\Discount;
  
  class DiscountsController extends Controller {
  
      public function __construct()
      {
          $this-&gt;data['admin_user'] = Session::get('admin_user');
  
          $this-&gt;data['message'] = Session::get('message');
  
          $this-&gt;data['admin_user'] = Auth::user();
      }
  
      /**
       * Display a listing of the resource.
       *
       * @return Response
       */
      public function index()
      {
          $this-&gt;data['discounts'] = Discount::orderBy('min_credits', 'asc')-&gt;get();
  
          return View::make('admin/discounts/index', $this-&gt;data);
      }
  
      /**
       * Update the specified resource in storage.
       *
       * @param  int  $id
       * @return Response
       */
      public function update(DiscountsEditRequest $request)
      {
          Discount::truncate();
  
          $row_count = count($request-&gt;min_credits);
          for($i=0; $i&lt;$row_count; $i++) {
              Discount::create([
                  'min_credits' =&gt; $request-&gt;min_credits[$i],
                  'max_credits' =&gt; $request-&gt;max_credits[$i],
                  'discount_percent' =&gt; $request-&gt;discount_percent[$i]
              ]);
          }
  
          Session::flash('message', '&lt;div class="alert alert-success" role="alert"&gt;The settings have been updated.&lt;/div&gt;');
          return redirect('admin/discounts');
      }
  
  }
  </code></pre>
  
  <p>If I submit the form with all fields filled in correctly it works fine, but if I purposely do something to make the validation fail such as submit a min_credits field as blank I get the following error:</p>
  
  <pre><code>ErrorException in helpers.php line 455:
  htmlentities() expects parameter 1 to be string, array given (View: C:\xampp\htdocs\clipitquick\resources\views\admin\discounts\index.blade.php)
  </code></pre>
  
  <p>This is the full stack trace:</p>
  
  <pre><code>in helpers.php line 455
  at CompilerEngine-&gt;handleViewException(object(ErrorException), '1') in PhpEngine.php line 43
  at PhpEngine-&gt;evaluatePath('C:\xampp\htdocs\clipitquick\storage\framework\views/b9d9b3d2ce2ab48a4dd7dd16ca46f5fe', array('__env' =&gt; object(Factory), 'app' =&gt; object(Application), 'errors' =&gt; object(ViewErrorBag), 'admin_user' =&gt; object(User), 'message' =&gt; null, 'discounts' =&gt; object(Collection))) in CompilerEngine.php line 57
  at CompilerEngine-&gt;get('C:\xampp\htdocs\clipitquick\resources\views/admin/discounts/index.blade.php', array('__env' =&gt; object(Factory), 'app' =&gt; object(Application), 'errors' =&gt; object(ViewErrorBag), 'admin_user' =&gt; object(User), 'message' =&gt; null, 'discounts' =&gt; object(Collection))) in View.php line 136
  at View-&gt;getContents() in View.php line 104
  at View-&gt;renderContents() in View.php line 78
  at View-&gt;render() in Response.php line 44
  at Response-&gt;setContent(object(View)) in Response.php line 202
  at Response-&gt;__construct(object(View)) in Router.php line 1188
  at Router-&gt;prepareResponse(object(Request), object(View)) in Router.php line 692
  at Router-&gt;Illuminate\Routing\{closure}(object(Request))
  at call_user_func(object(Closure), object(Request)) in Pipeline.php line 141
  at Pipeline-&gt;Illuminate\Pipeline\{closure}(object(Request)) in AdminAuth.php line 30
  at AdminAuth-&gt;handle(object(Request), object(Closure)) in Pipeline.php line 125
  at Pipeline-&gt;Illuminate\Pipeline\{closure}(object(Request))
  at call_user_func(object(Closure), object(Request)) in Pipeline.php line 101
  at Pipeline-&gt;then(object(Closure)) in Router.php line 693
  at Router-&gt;runRouteWithinStack(object(Route), object(Request)) in Router.php line 660
  at Router-&gt;dispatchToRoute(object(Request)) in Router.php line 618
  at Router-&gt;dispatch(object(Request)) in Kernel.php line 210
  at Kernel-&gt;Illuminate\Foundation\Http\{closure}(object(Request))
  at call_user_func(object(Closure), object(Request)) in Pipeline.php line 141
  at Pipeline-&gt;Illuminate\Pipeline\{closure}(object(Request)) in ShareErrorsFromSession.php line 55
  at ShareErrorsFromSession-&gt;handle(object(Request), object(Closure)) in Pipeline.php line 125
  at Pipeline-&gt;Illuminate\Pipeline\{closure}(object(Request)) in StartSession.php line 61
  at StartSession-&gt;handle(object(Request), object(Closure)) in Pipeline.php line 125
  at Pipeline-&gt;Illuminate\Pipeline\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 36
  at AddQueuedCookiesToResponse-&gt;handle(object(Request), object(Closure)) in Pipeline.php line 125
  at Pipeline-&gt;Illuminate\Pipeline\{closure}(object(Request)) in EncryptCookies.php line 40
  at EncryptCookies-&gt;handle(object(Request), object(Closure)) in Pipeline.php line 125
  at Pipeline-&gt;Illuminate\Pipeline\{closure}(object(Request)) in CheckForMaintenanceMode.php line 42
  at CheckForMaintenanceMode-&gt;handle(object(Request), object(Closure)) in Pipeline.php line 125
  at Pipeline-&gt;Illuminate\Pipeline\{closure}(object(Request))
  at call_user_func(object(Closure), object(Request)) in Pipeline.php line 101
  at Pipeline-&gt;then(object(Closure)) in Kernel.php line 111
  at Kernel-&gt;sendRequestThroughRouter(object(Request)) in Kernel.php line 84
  at Kernel-&gt;handle(object(Request)) in index.php line 51
  </code></pre>