Forum

Kohana: how to tran...
 
Powiadomienia
Wyczyść wszystko

Kohana: how to translate validation errors

1 Wpisy
1 Użytkownicy
0 Reactions
788 Widoki
0
Rozpoczynający temat

example

1 odpowiedź
0
Rozpoczynający temat

example method

    function action_add()
    {
        if ($this->request->post()) {
            try {
                $user = new Model_User();
                $user->values($this->request->post());
                $user->save();
            } catch (ORM_Validation_Exception  $exception) {
                $this->setError($exception->errors( 'models'));
            }
        }
    }

put this file inside application/messages/models/user.php

<?php defined('SYSPATH') OR die('No direct access allowed.');

return array(
    'username' => array(
        'not_empty' => 'musisz podać login',
    ),
    'email' => array(
        'not_empty' => 'e-mail nie może być pusty',
        'email' => 'Podany adres e-mail nie jest poprawny. Sprawdź czy jest we własciwej formie.',
        'max_length' => 'Hasło nie może być dłuższe niż :param2 znaków',
        'not_like_login' => 'Hasło nie może być takie same jak login'
    ),
);

Twoja odpowiedź

Nazwa autora

E-mail autora

Twoje zapytanie *

 
Podgląd 0 rewizje Zapisano
Udostępnij: