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.

43 lines
1.1 KiB

  1. <?php
  2. /**
  3. * @copyright NetMonsters <team@netmonsters.ru>
  4. * @link http://netmonsters.ru
  5. * @package Majestic
  6. * @subpackage Form
  7. * @since 2010-04-25
  8. * @version SVN: $Id$
  9. * @filesource $URL$
  10. */
  11. class FormViewHelper extends ViewHelper
  12. {
  13. protected $data = null;
  14. public function form($form = null)
  15. {
  16. if ($this->data === null) {
  17. if ($form == null) {
  18. throw new InitializationException('Form name required for helper init');
  19. }
  20. $this->data = Session::get($form, array());
  21. Session::del($form);
  22. }
  23. return $this;
  24. }
  25. public function value($field, $default = '')
  26. {
  27. if (isset($this->data['values'][$field])) {
  28. return $this->view->escape($this->data['values'][$field]);
  29. }
  30. return $this->view->escape($default);
  31. }
  32. public function message($fgrepield)
  33. {
  34. if (isset($this->data['messages'][$field])) {
  35. return '<span class="error">' . $this->view->escape($this->data['messages'][$field]) . '</span>';
  36. }
  37. return '';
  38. }
  39. }