1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace XoopsModules\Modulebuilder\Form; |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
You may not change or alter any portion of this comment or credits |
7
|
|
|
of supporting developers from this source code or any supporting source code |
8
|
|
|
which is considered copyrighted (c) material of the original comment or credit authors. |
9
|
|
|
|
10
|
|
|
This program is distributed in the hope that it will be useful, |
11
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
12
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
13
|
|
|
*/ |
14
|
|
|
/** |
15
|
|
|
* modulebuilder module. |
16
|
|
|
* |
17
|
|
|
* @copyright XOOPS Project (https://xoops.org) |
18
|
|
|
* @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) |
19
|
|
|
* |
20
|
|
|
* @since 2.5.5 |
21
|
|
|
* |
22
|
|
|
* @author Txmod Xoops <[email protected]> |
23
|
|
|
* |
24
|
|
|
*/ |
25
|
|
|
defined('XOOPS_ROOT_PATH') || die('Restricted access'); |
26
|
|
|
|
27
|
|
|
\XoopsLoad::load('XoopsFormLoader'); |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Form that will output as a theme-enabled HTML table. |
31
|
|
|
* |
32
|
|
|
* Also adds JavaScript to validate required fields |
33
|
|
|
*/ |
34
|
|
|
class ThemeForm extends \XoopsForm |
35
|
|
|
{ |
36
|
|
|
/** |
37
|
|
|
* create HTML to output the form as a theme-enabled table with validation. |
38
|
|
|
* |
39
|
|
|
* YOU SHOULD AVOID TO USE THE FOLLOWING Nocolspan METHOD, IT WILL BE REMOVED |
40
|
|
|
* |
41
|
|
|
* To use the noColspan simply use the following example: |
42
|
|
|
* |
43
|
|
|
* $colspan = new \XoopsFormDhtmlTextArea( '', 'key', $value, '100%', '100%' ); |
44
|
|
|
* $colspan->setNocolspan(); |
45
|
|
|
* $form->addElement( $colspan ); |
46
|
|
|
* |
47
|
|
|
* @return string |
48
|
|
|
*/ |
49
|
|
|
public function render() |
50
|
|
|
{ |
51
|
|
|
$ele_name = $this->getName(); |
52
|
|
|
//$ret = ($this->getTitle() ? '<div class=" center head ">' . $this->getTitle() . '</div>' : ''); |
53
|
|
|
$ret = NWLINE . '<form name="' . $ele_name . '" id="' . $ele_name . '" action="' . $this->getAction() . '" method="' . $this->getMethod() . '" onsubmit="return xoopsFormValidate_' . $ele_name . '();"' . $this->getExtra() . '>' . NWLINE; |
54
|
|
|
$hidden = ''; |
55
|
|
|
$class = 'even'; |
|
|
|
|
56
|
|
|
foreach ($this->getElements() as $ele) { |
57
|
|
|
if (!is_object($ele)) { |
58
|
|
|
$ret .= $ele; |
59
|
|
|
} else { |
60
|
|
|
if (!$ele->isHidden()) { |
61
|
|
|
$ret .= $ele->render(); |
|
|
|
|
62
|
|
|
} else { |
63
|
|
|
$hidden .= $ele->render(); |
|
|
|
|
64
|
|
|
} |
65
|
|
|
} |
66
|
|
|
} |
67
|
|
|
$ret .= NWLINE . ' ' . $hidden . NWLINE . '</form>'; |
68
|
|
|
$ret .= $this->renderValidationJS(true); |
69
|
|
|
|
70
|
|
|
return $ret; |
71
|
|
|
} |
72
|
|
|
} |
73
|
|
|
|