blob: d2808a8b401bc76d4d4d1d4f007b11784065a753 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
<?php
namespace Bitweaver\Plugins;
use Bitweaver\KernelTools;
/**
* Smarty plugin
* @package Smarty
* @subpackage plugins
*/
/**
* Smarty {formlabel} function plugin
*
* Type: function
* Name: formlabel
* Input:
* - label (required) - words that are displayed
* - mandatory (optional) - add a class formmandatory in the div
*/
function smarty_function_formlabel( $params,&$gBitSmarty ) {
global $gSmartyFormHorizontal;
$atts = '';
$class = 'control-label';
if( $gSmartyFormHorizontal ) {
$class .= ' col-sm-4';
}
foreach($params as $key => $val) {
switch( $key ) {
case 'class':
$class .= ' '.$val;
break;
case 'label':
$name = $val;
break;
case 'mandatory':
$mandatory = true;
default:
if( $val ) {
$atts .= ' '.$key.'="'.$val.'"';
}
break;
}
}
$html = '<label class="'.$class.'" ';
if (isset($mandatory) && $mandatory) {
$html .= ' required';
}
if( $atts != '' ) {
$html .= $atts;
}
$html .= '>';
if( empty( $params['no_translate'] ) ) {
$html .= KernelTools::tra( $name );
} else {
$html .= $name;
}
$html .= '</label>';
return $html;
}
|