diff options
Diffstat (limited to 'h-source/Library/Form')
-rwxr-xr-x | h-source/Library/Form/Form.php | 73 | ||||
-rwxr-xr-x | h-source/Library/Form/Hidden.php | 2 |
2 files changed, 65 insertions, 10 deletions
diff --git a/h-source/Library/Form/Form.php b/h-source/Library/Form/Form.php index a1a9fda..d1899a4 100755 --- a/h-source/Library/Form/Form.php +++ b/h-source/Library/Form/Form.php @@ -97,7 +97,7 @@ class Form_Form { //function to create the HTML of the form //$values: an associative array ('entryName'=>'value') - //$subset: subset to print + //$subset: subset to print (comma seprated list of string or array) public function render($values = null, $subset = null) { @@ -116,23 +116,78 @@ class Form_Form { $fenctype = isset($this->enctype) ? " enctype=".$this->enctype." " : null; $htmlForm = "<form $fname $fclass $fid action='".Url::getRoot($this->action)."' method='".$this->method."' $fenctype>\n"; - $subset = (isset($subset)) ? explode(',',$subset) : array_keys($values); + if (!isset($subset)) + { + $subset = array_keys($values); + } + else + { + $subset = !is_array($subset) ? explode(',',$subset) : $subset; + } +// $subset = (isset($subset)) ? explode(',',$subset) : array_keys($values); - foreach ($subset as $entry) + //first cicle: write the HTML of tabs if there are any + $tabsHtml = null; + $fCount = 0; + foreach ($subset as $key => $entry) { - - if (array_key_exists($entry,$this->entry)) + if (is_array($entry)) { - $value = array_key_exists($entry,$values) ? $values[$entry] : $this->entry[$entry]->defaultValue; - $htmlForm .= $this->entry[$entry]->render($value); + $currClass = $fCount === 0 ? "current_tab" : null; + $cleanKey = encode($key); + $tabsHtml .= "\t<li class='form_tab_li $currClass'><a rel='tab_$cleanKey' class='form_tab_a form_tab_a_$cleanKey' href='#'>$key</a></li>\n"; + $fCount++; + } + } + if (isset($tabsHtml)) + { + $htmlForm .= "<ul class='form_tab_ul'>\n$tabsHtml\n</ul>\n"; + } + + $fCount = 0; + foreach ($subset as $k => $entry) + { + + $cleanK = encode($k); + if (!is_array($entry)) + { + if (array_key_exists($entry,$this->entry)) + { + $value = array_key_exists($entry,$values) ? $values[$entry] : $this->entry[$entry]->defaultValue; + $htmlForm .= $this->entry[$entry]->render($value); + } + } + else + { + $tHtml = null; + $displClass = $fCount === 0 ? null : "display_none"; + foreach ($entry as $e) + { + if (array_key_exists($e,$this->entry)) + { + $value = array_key_exists($e,$values) ? $values[$e] : $this->entry[$e]->defaultValue; + $tHtml .= $this->entry[$e]->render($value); + } + } + $htmlForm .= "<div id='tab_$cleanK' class='tab_description_item $displClass'>$tHtml</div>"; + $fCount++; } - } + $htmlForm .= "<div class='submit_entry'>"; foreach ($this->submit as $name => $value) { - $htmlForm .= "<div class='inputEntry'>\n<input id='".$name."' type='submit' name='$name' value='$value'>\n</div>\n"; + if (!is_array($value)) + { + $htmlForm .= "<span class='submit_entry_$value'>".Html_Form::submit($name, $value, null, $name)."</span>"; + } + else + { + array_unshift($value,$name); + $htmlForm .= call_user_func_array(array("Html_Form","submit"),$value); + } } + $htmlForm .= "</div>"; $htmlForm .= "</form>\n"; return $htmlForm; } diff --git a/h-source/Library/Form/Hidden.php b/h-source/Library/Form/Hidden.php index c589662..db86713 100755 --- a/h-source/Library/Form/Hidden.php +++ b/h-source/Library/Form/Hidden.php @@ -33,7 +33,7 @@ class Form_Hidden extends Form_Entry public function render($value = null) { - $returnString = Html_Form::hidden($this->entryName, $value); + $returnString = Html_Form::hidden($this->entryName, $value, $this->className, $this->idName); return $returnString; } |