Laravel由于缓存而无法提交表单

时间:2018-07-23 05:57:23

标签: php laravel-5.2

我的Laravel表单在不清除缓存的情况下不会提交。我已经清除了缓存CTRL + F5(清除缓存),并且可以进行表单提交。否则,当我单击提交3到4次时,页面将刷新而不提交。我该如何解决这个问题?

这是我更新的代码:

     {!! Form::open(array('route' =>   
                'category.store','method'=>'POST','files'=>true)) !!}
            {!! csrf_field() !!}

        @if(count($errors))
        <div class="alert alert-danger">
            <strong>Whoops!</strong> There were some problems with your input.
            <br/>
            <ul>
                @foreach($errors->all() as $error)
                <li>{{ $error }}</li>
                @endforeach
            </ul>
        </div>
      @endif

      <div class="row">
        <div class="col-md-6">
         <div class="form-group">     
    {{ Form::label('Car Type', 'Car Type') }}
    {{ Form::text('cartype', null, array('class' => 'form-control')) }}
    <span class="text-danger">{{ $errors->first('cartype') }}</span>
        </div>
      </div>
     </div>
   {{ Form::close() }}

控制器:

public function store(Request $request)
{
     Validator::make($request->all(), [
        'cartype' => 'required|unique:car_category',

    ],
    [
    'image' => 'Please choose an image having extension jpg,png or jpeg.',
        'mimes' => 'Please choose an image having extension jpg,png or jpeg.',
        'integer' => 'Please enter valid value.',
        'between:1,12' => ' The Available seats must between 1 to 12.',
        'cartype.required' => ' The Car Type field is required.',

        ])->validate();


    $picture = new Car;

    $picture->cartype = Input::get('cartype');

    $picture->save();

}

1 个答案:

答案 0 :(得分:0)

首先,从您的表单中删除 layer2 = boto.connect_glacier(aws_access_key_id = ACCESS_KEY_ID, aws_secret_access_key = SECRET_ACCESS_KEY, region_name = 'your region name') 。 您的表格应该像这样。

{!! csrf_field() !!}

{{Form :: close()}}