X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=WEB-INF%2Flib%2Fform%2FForm.class.php;h=19dd0111f5cb75b308819daeb0703f6c1c939640;hb=48ba99d8257be57e5e43a03e80ab5d8c782b5295;hp=7814877f47023f0e54cec0210ecea849b67a3f28;hpb=d2df33e87f20af74c9339c15d3a7fbacd9560ded;p=timetracker.git diff --git a/WEB-INF/lib/form/Form.class.php b/WEB-INF/lib/form/Form.class.php index 7814877f..19dd0111 100644 --- a/WEB-INF/lib/form/Form.class.php +++ b/WEB-INF/lib/form/Form.class.php @@ -26,15 +26,10 @@ // | https://www.anuko.com/time_tracker/credits.htm // +----------------------------------------------------------------------+ -// +----------------------------------------------------------------------+ -// | -// | Class generates elements of specification HTML 4.01 -// | http://www.w3.org/TR/1999/REC-html401-19991224 -// | -// +----------------------------------------------------------------------+ - +// Form class is a container for HTML forms we use in the application. +// It contains an array of $elements - which are individual input controls +// belonging to a form. class Form { - var $name = ''; // Form name. var $elements = array(); // An array of input controls in form. @@ -79,22 +74,28 @@ class Form { if (isset($params['format'])) $el->setFormat($params['format']); break; + case 'textarea': + import('form.TextArea'); + $el = new TextArea($params['name']); + if (isset($params['maxlength'])) $el->setMaxLength($params['maxlength']); + break; + + case 'checkbox': + import('form.Checkbox'); + $el = new Checkbox($params['name']); + break; + + case 'hidden': + import('form.Hidden'); + $el = new Hidden($params['name']); + break; + + case 'submit': + import('form.Submit'); + $el = new Submit($params['name']); + break; + // TODO: refactoring ongoing down from here. - case "textarea": - import('form.TextArea'); - $el = new TextArea($params["name"]); - $el->setColumns(@$params["cols"]); - $el->setRows(@$params["rows"]); - if (isset($params["maxlength"])) $el->setMaxLength($params["maxlength"]); - break; - - case "checkbox": - import('form.Checkbox'); - $el = new Checkbox($params["name"]); - if (@$params["checked"]) $el->setChecked(true); - $el->setData(@$params["data"]); - break; - case "checkboxgroup": import('form.CheckboxGroup'); $el = new CheckboxGroup($params["name"]); @@ -109,19 +110,13 @@ class Form { $el = new Combobox($params["name"]); $el->setData(@$params["data"]); $el->setDataDefault(@$params["empty"]); + if (isset($params["multiple"])) { + $el->setMultiple($params["multiple"]); + $el->name .= '[]'; // Add brackets to the end of name to get back an array on POST. + } if (isset($params["datakeys"])) $el->setDataKeys($params["datakeys"]); break; - - case "hidden": - import('form.Hidden'); - $el = new Hidden($params["name"]); - break; - - case "submit": - import('form.Submit'); - $el = new Submit($params["name"]); - break; - + case "calendar": import('form.Calendar'); $el = new Calendar($params["name"]); @@ -144,7 +139,7 @@ class Form { if ($el!=null) { $el->setFormName($this->name); if (isset($params["id"])) $el->setId($params["id"]); - if (isset($GLOBALS["I18N"])) $el->localize($GLOBALS["I18N"]); + $el->localize(); if (isset($params["enable"])) $el->setEnabled($params["enable"]); if (isset($params["style"])) $el->setStyle($params["style"]); @@ -162,7 +157,7 @@ class Form { function addInputElement(&$el) { if ($el && is_object($el)) { - if (isset($GLOBALS["I18N"])) $el->localize($GLOBALS["I18N"]); + $el->localize(); $el->setFormName($this->name); $this->elements[$el->name] = &$el;