I’m attempting to load custom error messages to use when validating my ‘sign up’ form.
User model:
https://github.com/ashleyconnor/Egotist/blob/master/classes/model/user.php
Account Controller:
https://github.com/ashleyconnor/Egotist/blob/master/classes/controller/user/account.php
Sign Up View:
https://github.com/ashleyconnor/Egotist/blob/master/views/account/signup.php
I then placed user.php in /messages/models/user.php but my new error messages are not being displayed in the form.
<?php defined('SYSPATH') or die('No direct script access.');
return array
(
'username' => array
(
'not_empty' => 'your message',
'max_length' => 'your message',
'alpha_dash' => 'your message',
'default' => 'default message'
),
);
?>
https://github.com/ashleyconnor/Egotist/blob/master/messages/models/user.php
So submitting an empty form gives the following error messages:
- Username must not be empty
- Email Address must not be empty
- Password must not be empty
Which are the default ones.
From Kohana
Validationclass,errorsmethod source code:Try using
$errors = $post->errors('models/user')instead$errors = $post->errors('signup')