Source for file FormContainer.php
Documentation is available at FormContainer.php
6: * Copyright (c) 2004, 2009 David Grudl (http://davidgrudl.com)
8: * This source file is subject to the "Nette license" that is bundled
9: * with this package in the file license.txt.
11: * For more information please see http://nettephp.com
13: * @copyright Copyright (c) 2004, 2009 David Grudl
14: * @license http://nettephp.com/license Nette license
15: * @link http://nettephp.com
17: * @package Nette\Forms
22: require_once dirname(__FILE__) .
'/../ComponentContainer.php';
24: require_once dirname(__FILE__) .
'/../Forms/INamingContainer.php';
29: * Container for form controls.
31: * @author David Grudl
32: * @copyright Copyright (c) 2004, 2009 David Grudl
33: * @package Nette\Forms
35: * @property-read ArrayIterator $controls
36: * @property-read Form $form
40: /** @var FormGroup */
57: * Adds the specified component to the IComponentContainer.
62: * @throws InvalidStateException
64: public function addComponent(IComponent $component, $name, $insertBefore =
NULL)
75: * Iterates over all form controls.
76: * @return ArrayIterator
87: * @param bool throw exception if form doesn't exist?
92: return $this->lookup('Nette\Forms\Form', $need);
97: /********************* control factories ****************d*g**/
102: * Adds single-line text input control to the form.
103: * @param string control name
104: * @param string label
105: * @param int width of the control
106: * @param int maximum number of characters the user may enter
109: public function addText($name, $label =
NULL, $cols =
NULL, $maxLength =
NULL)
111: return $this[$name] =
new TextInput($label, $cols, $maxLength);
117: * Adds single-line text input control used for sensitive input such as passwords.
118: * @param string control name
119: * @param string label
120: * @param int width of the control
121: * @param int maximum number of characters the user may enter
124: public function addPassword($name, $label =
NULL, $cols =
NULL, $maxLength =
NULL)
127: $control->setPasswordMode(TRUE);
135: * Adds multi-line text input control to the form.
136: * @param string control name
137: * @param string label
138: * @param int width of the control
139: * @param int height of the control in text lines
142: public function addTextArea($name, $label =
NULL, $cols =
40, $rows =
10)
144: return $this[$name] =
new TextArea($label, $cols, $rows);
150: * Adds control that allows the user to upload files.
151: * @param string control name
152: * @param string label
153: * @return FileUpload
163: * Adds hidden form control used to store a non-displayed value.
164: * @param string control name
165: * @return HiddenField
175: * Adds check box control to the form.
176: * @param string control name
177: * @param string caption
188: * Adds set of radio button controls to the form.
189: * @param string control name
190: * @param string label
191: * @param array options from which to choose
196: return $this[$name] =
new RadioList($label, $items);
202: * Adds select box control that allows single item selection.
203: * @param string control name
204: * @param string label
205: * @param array items from which to choose
206: * @param int number of rows that should be visible
209: public function addSelect($name, $label =
NULL, array $items =
NULL, $size =
NULL)
211: return $this[$name] =
new SelectBox($label, $items, $size);
217: * Adds select box control that allows multiple item selection.
218: * @param string control name
219: * @param string label
220: * @param array options from which to choose
221: * @param int number of rows that should be visible
222: * @return MultiSelectBox
224: public function addMultiSelect($name, $label =
NULL, array $items =
NULL, $size =
NULL)
226: return $this[$name] =
new MultiSelectBox($label, $items, $size);
232: * Adds button used to submit form.
233: * @param string control name
234: * @param string caption
235: * @return SubmitButton
245: * Adds push buttons with no default behavior.
246: * @param string control name
247: * @param string caption
258: * Adds graphical button used to submit form.
259: * @param string control name
260: * @param string URI of the image
261: * @param string alternate text for the image
262: * @return ImageButton
264: public function addImage($name, $src =
NULL, $alt =
NULL)
272: * Adds naming container to the form.
273: * @param string name
274: * @return FormContainer
280: return $this[$name] =
$control;
286: * Adds control that repeats a specified prototype for each item in the list.
287: * @param string control name
288: * @return RepeaterControl
297: /********************* interface \ArrayAccess ****************d*g**/
302: * Adds the component to the container.
303: * @param string component name
315: * Returns component specified by name. Throws exception if component doesn't exist.
316: * @param string component name
317: * @return IComponent
318: * @throws InvalidArgumentException
328: * Does component specified by name exists?
329: * @param string component name
340: * Removes component from the container. Throws exception if component doesn't exist.
341: * @param string component name
347: if ($component !==
NULL) {