Шаблон не видит переменную :(

Рейтинг: 0Ответов: 1Опубликовано: 18.09.2014

При валидации формы в kohana, шаблон не видит переменную.

$errors = null;

if($_POST) {
    $_POST = Arr::map('trim', $_POST);
    $post = Validation::factory($_POST);
    $post->rule('login', 'not_empty');
    $post->rule('login', 'min_length', array(':value', 3));
    $post->rule('login', 'max_length', array(':value', 20));
    $post->rule('email', 'email');

    if($post->check()) {
        return true;
    } else $errors = $post->errors('validation');
}

var_dump($errors);

$content = View::factory('signup');
$this->template->title = 'Регистрация';
$this->template->errors = $errors;
$this->template->content = $content;

В шаблоне

<?php if(isset($errors['login'])) echo $errors['login']; ?>

в чем может быть загвоздка ?

Ответы

▲ 1Принят

Может не в тот шаблон выводите? Что дает var-dump? Засуньте его в шаблон и там вместо isset() напишите: var-dump($errors)