X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=plekit%2Fphp%2Fform.php;h=f56f02ad00afb84992ee34396b8dc67d46e1f9b0;hb=6a3ae6aeff154df1d916f78e966536959314fd8e;hp=0f6700230aa72679f134af32fbcf5e6b287d48b6;hpb=f99cfc8401815836073effa34c5cda024e77a3a9;p=plewww.git diff --git a/plekit/php/form.php b/plekit/php/form.php index 0f67002..f56f02a 100644 --- a/plekit/php/form.php +++ b/plekit/php/form.php @@ -12,9 +12,11 @@ class PlekitForm { // mandatory var $url; var $values; // a hash var=>value - default is empty array - var $method; // default is POST + var $method; // default is POST, can be changed with options + var $onSubmit; // can be set with options + var $onReset; // can be set with options - function PlekitForm ($full_url, $values, $method="POST") { + function PlekitForm ($full_url, $values, $options=NULL) { // so we can use the various l_* functions: // we parse the url to extract var-values pairs, // and add them to the 'values' argument if any @@ -29,12 +31,17 @@ class PlekitForm { $this->values=$values; // make strict xhtml happy - $this->method=strtolower($method); + $this->method="post"; if (isset($options['method']) && (!empty($options['method']))) $this->method=strtolower($options['method']); + $this->onSubmit=NULL; if (isset($options['onSubmit']) && (!empty($options['onSubmit']))) $this->onSubmit=$options['onSubmit']; + $this->onReset=NULL; if (isset($options['onReset']) && (!empty($options['onReset']))) $this->onReset=$options['onReset']; } function start () { print $this->start_html(); } function start_html () { - $html="
"; + $html="onSubmit) $html .= " onSubmit='$this->onSubmit'"; + if ($this->onReset) $html .= " onReset='$this->onReset'"; + $html .= ">"; if ($this->values) foreach ($this->values as $key=>$value) $html .= $this->hidden_html($key,$value); @@ -112,13 +119,15 @@ class PlekitForm { $encoded=htmlentities($options['label'],ENT_QUOTES); $html.=""; } - foreach ($selectors as $selector) { - $display=htmlentities($selector['display'],ENT_QUOTES); - $value=$selector['value']; - $html .= "