Back

laravel post request validation don't show ther errors ( validation Fail)


i try to set rule to validate post request for laravel form to store data but if i set any validation rule ( either pass or fail ) it will show just blank empty page . i using laravel 5 the form ( view ):

	@if (count($errors) > 0)
		<div class="alert alert-danger">
			<ul>
				@foreach ($errors->all() as $error)
					<li>{{ $error }}</li>
				@endforeach
			</ul>
		</div>
	@endif    
{!! Form::open(['action' => '[email protected]', 'method' => 'post']) !!}

	{!! Form::label('dateOfAgreement', 'Date of Agreement', ['class' => 'control-label']) !!}
	{!! Form::input('date', 'dateOfAgreement' , date('Y-m-d') , ['class' => 'form-control']) !!}
	
	{!! Form::submit('Submit', ['class' => 'button']) !!}

	{!! Form::close() !!}

Controller

public function store(StoreAgreementPostRequest $request)
	{
        $agreement= new RentalAgreement(array(

           
          
            'dateOfAgreement'   =>  $request->dateOfAgreement,
         
        ));


        $agreement->save();
        Session::flash('flash_message', 'Agreement successfully added! ');

        return view('home');
	}

StoreAgreementPostRequest

class StoreAgreementPostRequest extends Request {


public function authorize()
{
	return true;
}


public function rules()
{
	return [

       'premiseUse'=>'required|max:5'
	];
}

}

just shows the black page but if i remove the rules its works . but for all other forms in this application validation way works ,( all other forms and controllers works perfectly).

shez1983 replied 2 years ago

I am getting the same problem... I just had one element in the rules array which was working fine, but I added TWO extra optional elements and now everytime i press submit in the form, I get blank page (if i remove those two elements added, it all works fine)

by elements i mean input fields.

public function rules()
	{
		$rules = [
			'email'     => 'required|email',
            'name'      => 'alpha|min:3',
            'location'  => 'alpha|min:3',
		];

		return $rules;
	}

PS> i uploaded this to my digital ocean server & I dont get the error there! (On my local, i am using homestead & have also just updated laravel & other vendors to see if that would help)

ftiersch replied 2 years ago

You're validating the field premiseUse but there is no field with that name in your form.


Sign in to participate in this thread!


We'd like to thank these amazing companies for supporting us