XOOPS  2.6.0
SimpleForm.php
Go to the documentation of this file.
1 <?php
2 /*
3  You may not change or alter any portion of this comment or credits
4  of supporting developers from this source code or any supporting source code
5  which is considered copyrighted (c) material of the original comment or credit authors.
6 
7  This program is distributed in the hope that it will be useful,
8  but WITHOUT ANY WARRANTY; without even the implied warranty of
9  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 */
11 
12 namespace Xoops\Form;
13 
25 class SimpleForm extends Form
26 {
35  public function insertBreak($extra = '', $class = '')
36  {
37  $class = empty($class) ? '' : ' class="' . $class . '"';
38  $value = '<br' . $class . ' />' . $extra;
39  $ele = new Raw($value);
40  $this->addElement($ele);
41  }
42 
48  public function render()
49  {
50  $ret = $this->getTitle() . "\n<form name=\"" . $this->getName() . "\" id=\""
51  . $this->getName() . "\" action=\"" . $this->getAction() . "\" method=\""
52  . $this->getMethod() . "\"" . $this->getExtra() . ">\n";
53  foreach ($this->getElements() as $ele) {
54  /* @var $ele Element */
55  if (!$ele->isHidden()) {
56  if (!$ele instanceof Raw) {
57  $ret .= "<strong>" . $ele->getCaption() . "</strong><br />" . $ele->render() . "<br />\n";
58  } else {
59  $ret .= $ele->render();
60  }
61  } else {
62  $ret .= $ele->render() . "\n";
63  }
64  }
65  $ret .= "</form>\n";
66  return $ret;
67  }
68 }
addElement(Element $formElement, $required=false)
Definition: Form.php:206
insertBreak($extra= '', $class= '')
Definition: SimpleForm.php:35
getAction($encode=true)
Definition: Form.php:182
getName($encode=true)
Definition: Form.php:158
getTitle($encode=false)
Definition: Form.php:132
getElements($recurse=false)
Definition: Form.php:232