1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13:
14:
15: 16: 17: 18: 19: 20: 21: 22: 23:
24: class Horde_View_Helper_Form extends Horde_View_Helper_Base
25: {
26: private $_instanceTag = 'Horde_View_Helper_Form_InstanceTag_Form';
27:
28: public function formFor($objectName)
29: {
30: $args = func_get_args();
31: $options = is_array(end($args)) ? array_pop($args) : array();
32:
33: if (isset($options['url'])) {
34: $urlOptions = $options['url'];
35: unset($options['url']);
36: } else {
37: $urlOptions = array();
38: }
39:
40: if (isset($options['html'])) {
41: $htmlOptions = $options['html'];
42: unset($options['url']);
43: } else {
44: $htmlOptions = array();
45: }
46: echo $this->formTag($urlOptions, $htmlOptions);
47:
48: $options['end'] = '</form>';
49:
50: array_push($args, $options);
51: return call_user_func_array(array($this, 'fieldsFor'), $args);
52: }
53:
54: public function fieldsFor($objectName)
55: {
56: $args = func_get_args();
57: $options = is_array(end($args)) ? array_pop($args) : array();
58: $object = isset($args[1]) ? $args[1] : null;
59:
60: $builder = isset($options['builder'])
61: ? $options['builder']
62: : Horde_View_Base::$defaultFormBuilder;
63:
64: return new $builder($objectName, $object, $this->_view, $options);
65: }
66:
67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90:
91: public function label($objectName, $method, $text, $options = array())
92: {
93: $object = isset($options['object']) ? $options['object'] : null;
94: unset($options['object']);
95: $tag = new $this->_instanceTag($objectName, $method, $this->_view, $object);
96: return $tag->toLabelTag($text, $options);
97: }
98:
99: public function textField($objectName, $method, $options = array())
100: {
101: $object = isset($options['object']) ? $options['object'] : null;
102: unset($options['object']);
103: $tag = new $this->_instanceTag($objectName, $method, $this->_view, $object);
104: return $tag->toInputFieldTag('text', $options);
105: }
106:
107: public function passwordField($objectName, $method, $options = array())
108: {
109: $object = isset($options['object']) ? $options['object'] : null;
110: unset($options['object']);
111: $tag = new $this->_instanceTag($objectName, $method, $this->_view, $object);
112: return $tag->toInputFieldTag('password', $options);
113: }
114:
115: public function hiddenField($objectName, $method, $options = array())
116: {
117: $object = isset($options['object']) ? $options['object'] : null;
118: unset($options['object']);
119: $tag = new $this->_instanceTag($objectName, $method, $this->_view, $object);
120: return $tag->toInputFieldTag('hidden', $options);
121: }
122:
123: public function fileField($objectName, $method, $options = array())
124: {
125: $object = isset($options['object']) ? $options['object'] : null;
126: unset($options['object']);
127: $tag = new $this->_instanceTag($objectName, $method, $this->_view, $object);
128: return $tag->toInputFieldTag('file', $options);
129: }
130:
131: public function checkBox($objectName, $method, $options = array(),
132: $checkedValue = '1', $uncheckedValue = '0')
133: {
134: $object = isset($options['object']) ? $options['object'] : null;
135: unset($options['object']);
136: $tag = new $this->_instanceTag($objectName, $method, $this->_view, $object);
137: return $tag->toCheckBoxTag($options, $checkedValue, $uncheckedValue);
138: }
139:
140: public function radioButton($objectName, $method, $tagValue, $options = array())
141: {
142: $object = isset($options['object']) ? $options['object'] : null;
143: unset($options['object']);
144: $tag = new $this->_instanceTag($objectName, $method, $this->_view, $object);
145: return $tag->toRadioButtonTag($tagValue, $options);
146: }
147:
148: public function textArea($objectName, $method, $options = array())
149: {
150: $object = isset($options['object']) ? $options['object'] : null;
151: unset($options['object']);
152: $tag = new $this->_instanceTag($objectName, $method, $this->_view, $object);
153: return $tag->toTextAreaTag($options);
154: }
155: }
156: