3 * Object-oriented HTML input field with validation
5 * @author Ant P <p@cpi.merseine.nu>
6 * @license http://specialops.ath.cx/repos/so2/trunk/COPYING (New BSD Licence)
15 function __construct($name, $value = '', $length = 20)
18 $this->value
= $value;
19 $this->maxlength
= $length;
22 function check_value()
24 if ( ! isset($_POST[$this->name
])
25 or $this->maxlength
&& strlen($_POST[$this->name
]) > $this->maxlength
) {
26 throw new OutOfBoundsException('Bad or no value given for form field "'.$this->name
);
33 $field = '<input type="text"';
35 foreach ( $this as $k => $v )
37 $field .= " $k=\"$v\"";
39 if ( is_null($this->default) && isset($_POST[$this->name
]) )
40 $field .= ' value="'.$_POST[$this->name
].'"';