Custom message seems not to work
Using custom $message variable to replace the default error message by including this code in controller, but it won't work for now:
$messages = array( 'dob' => 'Date of birth instead of dob field' );
$validation = Validator::make($input, User::$rules, $messages);
Hm that's weird, Former directly fetches the MessageBag from session, if your message is set correctly it should use it. Can you past your form's code ?
Hi anahkiasen, here is the code I used before. Currently I'm still mixing Former and Form. in controller:
public function store()
{
$input = Input::all();
// change 'dob' error massage
$messages = array(
'dob.required' => 'Test',
// 'before' => 'Second test'
);
$validation = Validator::make($input, User::$rules, $messages);
if ($validation->passes())
{
$this->user->create($input);
return Redirect::route('users.index');
}
return Redirect::route('users.create')
->withInput()
->withErrors($validation);
}
in View:
I've tried code based closely on the above for both Twitter Bootstrap 2 and 3, and it works fine for me in both cases.
Are you using the master or the develop branch? Which framework are you using? Could you paste your rules and your full form?