You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1.0 KiB
42 lines
1.0 KiB
<?php
|
|
/**
|
|
* @copyright NetMonsters <team@netmonsters.ru>
|
|
* @link http://netmonsters.ru
|
|
* @package Majestic
|
|
* @subpackage Form
|
|
* @since 2010-04-25
|
|
*/
|
|
|
|
class FormViewHelper extends ViewHelper
|
|
{
|
|
|
|
protected $data = null;
|
|
|
|
public function form($form = null)
|
|
{
|
|
if ($this->data === null) {
|
|
if ($form == null) {
|
|
throw new InitializationException('Form name required for helper init');
|
|
}
|
|
$this->data = Session::get($form, array());
|
|
Session::del($form);
|
|
}
|
|
return $this;
|
|
}
|
|
|
|
public function value($field, $default = '')
|
|
{
|
|
if (isset($this->data['values'][$field])) {
|
|
return $this->view->escape($this->data['values'][$field]);
|
|
}
|
|
return $this->view->escape($default);
|
|
}
|
|
|
|
public function message($field)
|
|
{
|
|
if (isset($this->data['messages'][$field])) {
|
|
return '<span class="error">' . $this->view->escape($this->data['messages'][$field]) . '</span>';
|
|
}
|
|
return '';
|
|
}
|
|
}
|