From 12bbca2e0528f983d529885c32fb98e7d411be0e Mon Sep 17 00:00:00 2001 From: Michael Klier Date: Mon, 29 Oct 2007 15:10:13 +0100 Subject: added makeFileField method to form class darcs-hash:20071029141013-23886-ca99a6bff50766f2015f071d89fcc3265746b3b5.gz --- inc/form.php | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'inc') diff --git a/inc/form.php b/inc/form.php index 77b76dd15..fbba80296 100644 --- a/inc/form.php +++ b/inc/form.php @@ -427,6 +427,21 @@ function form_makePasswordField($name, $label=null, $id='', $class='', $attrs=ar return array_merge($elem, $attrs); } +/** + * form_makeFileField + * + * Create a form element for a file input element with label + * + * @see form_makeField + * @author Michael Klier + */ +function form_makeFileField($name, $label=null, $id='', $class='', $attrs=array()) { + if (is_null($label)) $label = $name; + $elem = array('_elem'=>'filefield', '_text'=>$label, '_class'=>$class, + 'id'=>$id, 'name'=>$name, 'class'=>'edit'); + return array_merge($elem, $attrs); +} + /** * form_makeCheckboxField * @@ -728,6 +743,31 @@ function form_passwordfield($attrs) { return $s; } +/** + * form_filefield + * + * Print the HTML for a file input field. + * _class : class attribute used on the label tag + * _text : Text to display before the input. Not escaped + * _maxlength : Allowed size in byte + * _accept : Accepted mime-type + * Other attributes are passed to buildAttributes() for the input tag + * + * @author Michael Klier + */ +function form_filefield($attrs) { + $s = '