====== Formulaire de contact ====== ===== Controller ===== beforeFilter('csrf', array('on' => 'post')); } public function getIndex(){ return View::make('contact'); } public function postIndex(){ $rules = array( 'nom' => 'required', 'email' => 'required|email', 'objet' => 'required|min:3', 'Message' => 'required|min:5' ); $messages = array( 'email.required' => 'L\'adresse e-mail est obligatoire' ); $v = Validator::make(Input::all(), $rules, $messages); if($v->passes()){ Mail::send('emails.contact', Input::all(), function($m){ $m->to('info@gmail.com')->subject('[Mon site] Contact via le site web'); }); return Redirect::to('contact')->with('flash_success','Le message a bien été envoyé.'); }else{ return Redirect::to('contact')->withErrors($v)->withInput(Input::all()); } } } ===== Vue ===== @extends('layouts.master') @section('contenu')
{{Form::open(array('url'=>'contact','method'=>'post','id'=>'formSB'))}}
Formulaire de contact
{{Form::label('nom','Nom', array('class'=>'control-label'))}} {{Form::text('nom','',array('maxlength'=>40, 'size'=>20 ))}} {{ $errors->has('nom') ? $errors->first('nom') : '' }}
{{Form::label('email','E-mail', array('class'=>'control-label'))}} {{Form::text('email','',array('maxlength'=>100, 'size'=>20))}} {{ $errors->has('email') ? $errors->first('email') : '' }}
{{Form::label('objet','Objet', array('class'=>'control-label'))}} {{Form::text('objet','',array('maxlength'=>150, 'size'=>20))}} {{ $errors->has('objet') ? $errors->first('objet') : '' }}
{{Form::label('Message','Message', array('class'=>'control-label'))}} {{Form::textarea('Message','',array('cols'=>20, 'rows'=>4))}}
{{ $errors->has('Message') ? $errors->first('Message') : '' }}
{{Form::submit('Envoyer',array('class'=>'btn'))}}
{{Form::token()}} {{Form::close()}}
@stop