X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=plekit%2Fphp%2Fform.php;h=f12d53e98d7a089fdd4e21d1ea588d3a268dfd2e;hb=eeb11c7fedb5ddceee3884a4b7509d60e84714b8;hp=45a8d7725f1384805f68e7a05ea0b729226fd5db;hpb=847006de47d4f1868cecf6126801a94e26f709ad;p=plewww.git diff --git a/plekit/php/form.php b/plekit/php/form.php index 45a8d77..f12d53e 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 @@ -28,12 +30,18 @@ class PlekitForm { if ( $url_values ) $values=array_merge($values,$url_values); $this->values=$values; - $this->method=$method; + // make strict xhtml happy + $this->method="post"; if ($options['method']) $this->method=strtolower($options['method']); + $this->onSubmit=NULL; if ($options['onSubmit']) $this->onSubmit=$options['onSubmit']; + $this->onReset=NULL; if ($options['onReset']) $this->onReset=$options['onReset']; } function start () { print $this->start_html(); } function start_html () { - $html="
method action='$this->url' enctype='multipart/form-data'>"; + $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); @@ -63,7 +71,7 @@ class PlekitForm { static function input_html ($type,$name,$value,$options=NULL) { if ( ! $options) $options=array(); $html="$display"; } static function textarea_html ($name,$value,$cols,$rows) { - return ""; + return ""; } // selectors is an array of hashes with the following keys @@ -111,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 .= "