3
* Copyright 2007-2008 Maintainable Software, LLC
4
* Copyright 2008-2012 Horde LLC (http://www.horde.org/)
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
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
24
class Horde_View_Helper_Form_Builder
32
public function __construct($objectName, $object, $view, $options)
34
$this->_objectName = $objectName;
35
$this->_object = $object;
38
$this->_end = isset($options['end']) ? $options['end'] : '';
39
unset($options['end']);
40
$this->_options = $options;
43
public function __call($method, $args)
46
throw new InvalidArgumentException('No object property specified');
48
$objectProperty = $args[0];
49
$options = array_merge(isset($args[1]) ? $args[1] : array(),
50
array('object' => $this->_object));
52
return $this->_view->{$method}($this->_objectName, $objectProperty, $options);
55
public function fieldsFor($name)
57
$name = "{$this->_objectName}[$name]";
58
$args = func_get_args();
60
return call_user_func_array(array($this->_view, 'fieldsFor'), $args);
63
public function checkBox($method, $options = array(), $checkedValue = '1',
64
$uncheckedValue = '0')
66
$options = array_merge($options, array('object' => $this->_object));
67
return $this->_view->checkBox($this->_objectName, $method, $options, $checkedValue, $uncheckedValue);
70
public function radioButton($method, $tagValue, $options = array())
72
$options = array_merge($options, array('object' => $this->_object));
73
return $this->_view->radioButton($this->_objectName, $method, $tagValue, $options);
76
public function submit($value = 'Save changes', $options = array())
78
$options = array_merge(array('id' => "{$this->_objectName}_submit"), $options);
79
return $this->_view->submitTag($value, $options);