Overview

Packages

  • View
    • Helper

Classes

  • Horde_View_Helper_Base
  • Horde_View_Helper_Benchmark
  • Horde_View_Helper_Benchmark_Timer
  • Horde_View_Helper_Block
  • Horde_View_Helper_Capture
  • Horde_View_Helper_Capture_Base
  • Horde_View_Helper_Capture_ContentFor
  • Horde_View_Helper_Date
  • Horde_View_Helper_Debug
  • Horde_View_Helper_Form
  • Horde_View_Helper_Form_Builder
  • Horde_View_Helper_Form_InstanceTag_Base
  • Horde_View_Helper_Form_InstanceTag_Form
  • Horde_View_Helper_FormTag
  • Horde_View_Helper_Javascript
  • Horde_View_Helper_Number
  • Horde_View_Helper_Tag
  • Horde_View_Helper_Text
  • Horde_View_Helper_Text_Cycle
  • Horde_View_Helper_Url
  • Overview
  • Package
  • Class
  • Tree
 1: <?php
 2: /**
 3:  * Copyright 2007-2008 Maintainable Software, LLC
 4:  * Copyright 2008-2012 Horde LLC (http://www.horde.org/)
 5:  *
 6:  * @author     Mike Naberezny <mike@maintainable.com>
 7:  * @author     Derek DeVries <derek@maintainable.com>
 8:  * @author     Chuck Hagenbuch <chuck@horde.org>
 9:  * @license    http://www.horde.org/licenses/bsd
10:  * @category   Horde
11:  * @package    View
12:  * @subpackage Helper
13:  */
14: 
15: /**
16:  * @author     Mike Naberezny <mike@maintainable.com>
17:  * @author     Derek DeVries <derek@maintainable.com>
18:  * @author     Chuck Hagenbuch <chuck@horde.org>
19:  * @license    http://www.horde.org/licenses/bsd
20:  * @category   Horde
21:  * @package    View
22:  * @subpackage Helper
23:  */
24: class Horde_View_Helper_Form_Builder
25: {
26:     private $_objectName;
27:     private $_object;
28:     private $_view;
29:     private $_options;
30:     private $_end;
31: 
32:     public function __construct($objectName, $object, $view, $options)
33:     {
34:         $this->_objectName = $objectName;
35:         $this->_object     = $object;
36:         $this->_view       = $view;
37: 
38:         $this->_end = isset($options['end']) ? $options['end'] : '';
39:         unset($options['end']);
40:         $this->_options = $options;
41:     }
42: 
43:     public function __call($method, $args)
44:     {
45:         if (empty($args)) {
46:             throw new InvalidArgumentException('No object property specified');
47:         }
48:         $objectProperty = $args[0];
49:         $options        = array_merge(isset($args[1]) ? $args[1] : array(),
50:                                       array('object' => $this->_object));
51: 
52:         return $this->_view->{$method}($this->_objectName, $objectProperty, $options);
53:     }
54: 
55:     public function fieldsFor($name)
56:     {
57:         $name = "{$this->_objectName}[$name]";
58:         $args = func_get_args();
59:         $args[0] = $name;
60:         return call_user_func_array(array($this->_view, 'fieldsFor'), $args);
61:     }
62: 
63:     public function checkBox($method, $options = array(), $checkedValue = '1',
64:                              $uncheckedValue = '0')
65:     {
66:         $options = array_merge($options, array('object' => $this->_object));
67:         return $this->_view->checkBox($this->_objectName, $method, $options, $checkedValue, $uncheckedValue);
68:     }
69: 
70:     public function radioButton($method, $tagValue, $options = array())
71:     {
72:         $options = array_merge($options, array('object' => $this->_object));
73:         return $this->_view->radioButton($this->_objectName, $method, $tagValue, $options);
74:     }
75: 
76:     public function submit($value = 'Save changes', $options = array())
77:     {
78:         $options = array_merge(array('id' => "{$this->_objectName}_submit"), $options);
79:         return $this->_view->submitTag($value, $options);
80:     }
81: 
82:     public function end()
83:     {
84:         echo $this->_end;
85:     }
86: }
87: 
API documentation generated by ApiGen