Esempio n. 1
0
 function renderStTag()
 {
     self::$sForm[] = $this;
     self::$sCount = count(self::$sForm);
     $out = array();
     foreach ($this->form->getHTMLProp() as $k => $v) {
         $out[] = "{$k}=\"{$v}\"";
     }
     $fields = $this->form->getFields();
     $labelTags = $this->find(array(array("type" => "label")));
     foreach ($labelTags as $tag) {
         if ($tag instanceof Html) {
             foreach ($tag->source as $source) {
                 if (isset($fields[$source])) {
                     $fields[$source]->getLabelAttStatic($tag->opt, $tag->type, $tag->content);
                 } else {
                     $tag->opt['style'] = "display:none;";
                 }
             }
         }
     }
     $inputTags = $this->find(array(array("type" => "hint")));
     foreach ($inputTags as $tag) {
         if ($tag instanceof Html) {
             foreach ($tag->source as $source) {
                 if (isset($fields[$source])) {
                     $fields[$source]->getHintAttStatic($tag->opt, $tag->type, $tag->content);
                 } else {
                     $tag->opt['style'] = "display:none;";
                 }
             }
         }
     }
     $inputTags = $this->find(array(array("type" => "input")));
     foreach ($inputTags as $tag) {
         if ($tag instanceof Html) {
             foreach ($tag->source as $source) {
                 if (isset($fields[$source])) {
                     $fields[$source]->getInputAttStatic($tag->opt, $tag->type, $tag->content);
                     unset($fields[$source]);
                 } else {
                     $tag->opt['style'] = "display:none;";
                 }
             }
         }
     }
     foreach ($fields as $n => $f) {
         if (!$f instanceof Button) {
             $this->addChild($label = new DynHtml("label", [], [], "", $n));
             $f->getLabelAttStatic($label->opt, $label->type, $label->content);
         }
         $this->addChild($input = new DynHtml("input", [], [], "", $n));
         $f->getInputAttStatic($input->opt, $input->type, $input->content);
     }
     return "<form " . implode(" ", $out) . "><?php \$form = " . $this->var->toPHP() . "; \$form->process(); ?>";
 }
Esempio n. 2
0
 static function toStTag(&$d, H\Form $form)
 {
     foreach ($d["source"] as $source) {
         $form->getField($source)->getDynamicAtt($d['base'], $d['opt'], $d['type'], $d['content']);
     }
     $out = "<" . $d['type'] . " ";
     foreach ($d['opt'] as $k => $v) {
         if (is_array($v)) {
             foreach ($v as $k2 => $v2) {
                 if ($v[$k2] instanceof Text) {
                     $v[$k2] = eval('return ' . $v[$k2]->toPHP() . ';');
                 }
             }
             $v = implode(" ", $v);
         }
         if ($v instanceof H\Text) {
             $v = eval('return ' . $v->toPHP() . ';');
         }
         $out .= $k . "=\"" . htmlspecialchars($v) . "\" ";
     }
     $out .= in_array($d['type'], self::$selfCloseTags) ? "/>" : ">";
     return $out;
 }