Bonjour à tous !

J'ai un problème lors de la validation de mon formulaire d'inscription.
Voici mon code :

views/user/signup.blade.php

@section('content')
@if(Session::has('success'))
 <div class="alert alert-success">{{ Session::get('success') }}</div>
@endif
<div class="form-horizontal col-sm-5 col-sm-offset-3" role="form">
 <h2>Inscription</h2>
 {{ Form::open(array('url' => 'user/signup', 'method' => 'post', 'class' => 'well')) }}
 {{ Form::token() }}
 <div class="form-group has-feedback @if($errors->first('username')) has-error @endif">
 <div class="col-sm-12">
 {{ Form::text('username', Input::old('username'), array('class' => 'form-control', 'placeholder' => 'Votre pseudo')) }}
 @if($errors->first('username')) <span class="glyphicon glyphicon-remove form-control-feedback"></span> @endif
 {{ $errors->first('username', '<span class="text-danger">:message</span>')}}
 </div>
 </div>

 <div class="form-group has-feedback @if($errors->first('email')) has-error @endif">
 <div class="col-sm-12">
 {{ Form::text('email', Input::old('email'), array('class' => 'form-control', 'placeholder' => 'Votre email')) }}
 @if($errors->first('email')) <span class="glyphicon glyphicon-remove form-control-feedback"></span> @endif
 {{ $errors->first('email', '<span class="text-danger">:message</span>')}}
 </div>
 </div>

 <div class="form-group has-feedback @if($errors->first('password')) has-error @endif">
 <div class="col-sm-12">
 {{ Form::password('password', array('class' => 'form-control', 'placeholder' => 'Mot de passe')) }}
 @if($errors->first('password')) <span class="glyphicon glyphicon-remove form-control-feedback"></span> @endif
 {{ $errors->first('password', '<span class="text-danger">:message</span>')}}
 </div>
 </div>

 <div class="form-group has-feedback @if($errors->first('password_confirm')) has-error @endif">
 <div class="col-sm-12">
 {{ Form::password('password_confirm', array('class' => 'form-control', 'placeholder' => 'Confirmez le mot de passe')) }}
 @if($errors->first('password_confirm')) <span class="glyphicon glyphicon-remove form-control-feedback"></span> @endif
 {{ $errors->first('password_confirm', '<span class="text-danger">:message</span>')}}
 </div>
 </div>
 {{ Form::submit('Valider', array('class' => 'btn btn-primary')) }}
 {{ HTML::link('/', 'Annuler', array('class' => 'btn btn-default')) }}
 {{ Form::close() }}
</div>
@endsection

controllers/UserController.php

class UserController extends BaseController {
 public function __construct() {
 $this->beforeFilter('auth', array('only' => array('getIndex', 'getLogout')));
 $this->beforeFilter('csrf', array('on' => 'post'));
 }
 public function getSignup() {
 if(Auth::check()) { return Redirect::to('user'); }
 $this->layout->title = 'Inscription';
 $this->layout->content = View::make('user.signup');
 }
 public function postSignup() {
 if(Auth::check()) { return Redirect::to('user'); }
 $rules = array(
 'username' => 'required|unique:users|betweed:3,20',
 'email' => 'required|email|unique:users',
 'password' => 'required|min:5|confirmed', 
 'password_confirm' => 'required|min:5'
 );
 $validation = Validator::make(Input::all(), $rules);
 if($validation->fails()) {
 return Redirect::to('user/signup')->withErrors($validation)->withInput();
 }
 else {
 $data = array(
 'username' => Input::get('username'),
 'email' => Input::get('email'),
 'password' => Hash::make(Input::get('password'))
 );
 if(User::create($data)) {
 Session::flash('success', 'Inscripton terminée');
 }
 }
 return Redirect::to('user/signup');
 }
}

J'ai ce message d'erreur lors de l'envoi de mon formulaire :
[BadMethodCallException
Method [validateBetweed] does not exist.

Apparemment la ligne qui pose problème est dans UserController.php:

if($validation->fails())

Est ce que quelqu'un peut m'aider car je ne vois vraiment d'où cela peux provenir...

Merci d'avance,
Bonne journée à tous !

1 réponse


barbuslex
Auteur
Réponse acceptée

C'est bon c'est mes yeux en fait ^^

Il fallait juste remplacer dans UserController.php

betweed

Par :

between