Ashley W
Ashley W

Reputation: 103

Laravel validation code - view, model or controller

I am following a tutorial on Laravel 4 and the following validations are placed in the view

<form action="{{ URL::route('account-create-post') }}" method="post" >
<div class="field">
    Email: <input type="text" name="email" {{ (Input::old('email')) ? 'value="' . e(input::old('email')) . ' " ' : ''}}>
    @if($errors->has('email'))
        {{ $errors->first('email') }}
    @endif  
</div>

It works, but seems to be counter to the MVC approach - should such validations be created in the model or controller?

Upvotes: 0

Views: 327

Answers (1)

user2629998
user2629998

Reputation:

This code only displays validation errors, the actual validation takes place in the controller.

Upvotes: 1

Related Questions