From b2bc77d5608f1e3bd927125f963820091f864580 Mon Sep 17 00:00:00 2001 From: Tom N Harris Date: Sat, 6 Oct 2007 21:57:20 +0200 Subject: Avoid duplicate attributes in forms darcs-hash:20071006195720-6942e-d95785f967bab4f89a3b61dc4467e3902a6b6fdf.gz --- inc/form.php | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) (limited to 'inc/form.php') diff --git a/inc/form.php b/inc/form.php index e03591e88..ac58906c8 100644 --- a/inc/form.php +++ b/inc/form.php @@ -320,7 +320,8 @@ function form_makeCloseTag($tag) { * @author Tom N Harris */ function form_makeWikiText($text, $attrs=array()) { - $elem = array('_elem'=>'wikitext', '_text'=>$text); + $elem = array('_elem'=>'wikitext', '_text'=>$text, + 'class'=>'edit', 'cols'=>'80', 'rows'=>'10'); return array_merge($elem, $attrs); } @@ -341,7 +342,8 @@ function form_makeWikiText($text, $attrs=array()) { function form_makeButton($type, $act, $value='', $attrs=array()) { if ($value == '') $value = $act; //$name = (!empty($act)) ? 'do[$act]' : null; - $elem = array('_elem'=>'button', 'type'=>$type, '_action'=>$act, 'value'=>$value); + $elem = array('_elem'=>'button', 'type'=>$type, '_action'=>$act, + 'value'=>$value, 'class'=>'button'); if (!empty($attrs['accesskey']) && empty($attrs['title'])) { $attrs['title'] = $value . ' [ALT+'.strtoupper($attrs['accesskey']).']'; } @@ -400,7 +402,7 @@ function form_makeFieldRight($type, $name, $value='', $label=null, $id='', $clas function form_makeTextField($name, $value='', $label=null, $id='', $class='', $attrs=array()) { if (is_null($label)) $label = $name; $elem = array('_elem'=>'textfield', '_text'=>$label, '_class'=>$class, - 'id'=>$id, 'name'=>$name, 'value'=>$value); + 'id'=>$id, 'name'=>$name, 'value'=>$value, 'class'=>'edit'); return array_merge($elem, $attrs); } @@ -416,7 +418,7 @@ function form_makeTextField($name, $value='', $label=null, $id='', $class='', $a function form_makePasswordField($name, $label=null, $id='', $class='', $attrs=array()) { if (is_null($label)) $label = $name; $elem = array('_elem'=>'passwordfield', '_text'=>$label, '_class'=>$class, - 'id'=>$id, 'name'=>$name); + 'id'=>$id, 'name'=>$name, 'class'=>'edit'); return array_merge($elem, $attrs); } @@ -614,7 +616,10 @@ function form_hidden($attrs) { * @author Tom N Harris */ function form_wikitext($attrs) { - return ''; @@ -631,7 +636,7 @@ function form_wikitext($attrs) { */ function form_button($attrs) { $p = (!empty($attrs['_action'])) ? 'name="do['.$attrs['_action'].']" ' : ''; - return ''; + return ''; } /** @@ -685,10 +690,12 @@ function form_fieldright($attrs) { * @author Tom N Harris */ function form_textfield($attrs) { + // mandatory attributes + unset($attrs['type']); $s = ''; + $s .= ''; if (preg_match('/(^| )block($| )/', $attrs['_class'])) $s .= '
'; return $s; @@ -705,10 +712,12 @@ function form_textfield($attrs) { * @author Tom N Harris */ function form_passwordfield($attrs) { + // mandatory attributes + unset($attrs['type']); $s = ''; + $s .= ''; if (preg_match('/(^| )block($| )/', $attrs['_class'])) $s .= '
'; return $s; @@ -725,6 +734,8 @@ function form_passwordfield($attrs) { * @author Tom N Harris */ function form_checkboxfield($attrs) { + // mandatory attributes + unset($attrs['type']); $s = '