Validator, captcha, form, #16
git-svn-id: svn+ssh://code.netmonsters.ru/svn/majestic/branches/evo@141 4cb57b5f-5bbd-dd11-951b-001d605cbbc5
This commit is contained in:
44
form/FormViewHelper.php
Normal file
44
form/FormViewHelper.php
Normal file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright NetMonsters <team@netmonsters.ru>
|
||||
* @link http://netmonsters.ru
|
||||
* @package Majestic
|
||||
* @subpackage Form
|
||||
* @since 2010-04-25
|
||||
* @version SVN: $Id$
|
||||
* @filesource $URL$
|
||||
*/
|
||||
|
||||
class FormViewHelper extends ViewHelper
|
||||
{
|
||||
|
||||
protected $data = null;
|
||||
|
||||
public function form($form = null)
|
||||
{
|
||||
if ($this->data === null) {
|
||||
if ($form == null) {
|
||||
throw new Exception('Form name required for helper init');
|
||||
}
|
||||
$this->data = Session::get($form, array());
|
||||
Session::del($form);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function value($field)
|
||||
{
|
||||
if (isset($this->data['values'][$field])) {
|
||||
return $this->view->escape($this->data['values'][$field]);
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
public function message($field)
|
||||
{
|
||||
if (isset($this->data['messages'][$field])) {
|
||||
return '<span class="error">' . $this->view->escape($this->data['messages'][$field]) . '</span>';
|
||||
}
|
||||
return '';
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user