PHP/Kohana Accessing variable defined in base controller in a view -
i have variable defined in class
controller_application extends controller_template
i have defined variable $form_errors within controller_application class below
public $form_errors = array();
public function before() { parent::before(); view::set_global('site_name', 'sitename'); view::bind_global('form_errors', $form_errors); } $form_errors set method called manageerrors, defined within controller_application. manageerrors called every time other controllers when exception or errors occurs.
public function manageerror($errorcode, $extraerrors=null) { if ($errorcode == controller_application::msgemailexists) array_push($this->form_errors, "email provided in use."); } i trying access $form_errors in view, display errors message holds. however, when trying print values, prints null.
manageerror accessed below
public function action_index() { $this->template->content = view::factory('vsignin')->render(); $this->manageerror(controller_application::msgemailexists); } in vsignin.php
<?php if ($form_errors): ?> <p class="message">some errors encountered, please check details entered.</p> <ul class="errors"> <?php foreach ($form_errors $message): ?> <li><?php echo $message ?></li> <?php endforeach ?> <?php endif ?> can help me figure out why th $form_errors printing null?
thanks
i need give $this->form_errors within bind_global(), , did trick.
php kohana kohana-3.3
No comments:
Post a Comment