-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathforms_multi.php
More file actions
88 lines (78 loc) · 2.16 KB
/
Copy pathforms_multi.php
File metadata and controls
88 lines (78 loc) · 2.16 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?php
class fe_multi extends fe_ext {
#Include support for sets of fields.
protected $subelms;
protected $multi;
public function __construct($array=false) {
$this->subelms = array();
parent::__construct($array);
}
public function __invoke($pat='auto',$ext_tag='div') {
$this->gen_subelms();
if (!$this->multi) return parent::__invoke($pat);
if ($pat == 'l_grand') return parent::__invoke('l');
$gen = "";
if ($ext_tag):
$gen.= "<$ext_tag";
$tmp = $this->putElementStd_light();
if ($tmp) $gen.= " $tmp";
$gen.= ">\n";
endif;
foreach ($this->subelms as $one):
$gen.= $one($pat);
endforeach;
if ($ext_tag):
$gen.= "</$ext_tag>\n";
endif;
return $gen;
}
protected function putValList($arr) {
parent::putValList($arr);
$this->subelms = array();
}
protected function gen_subelms() {
if ($this->subelms) return;
$this->multi = false;
if ($this->type == 'multi_radio') $this->multi = true;
if ($this->type == 'multi_checkbox') $this->multi = true;
if (!$this->multi) return;
$i = 0;
if ($this->type == 'multi_radio') $type = 'radio';
else $type = 'checkbox';
foreach ($this->options as $o):
$this->subelms[] = $this->gen_subelm($o,$i,$type);
$i++;
endforeach;
}
protected function gen_subelm($opt,$i,$type) {
$x = new fe_single();
$x->set('type',$type);
if ($this->id) $x->set('id',$this->id."_child_".$i);
if ($this->cls) $x->set('class',$this->class.'_child');
if ($this->labelId) $x->set('labelId',$this->labelId.'_child_'.$i);
if ($this->labelCls) $x->set('labelCls',$this->labelCls.'_child');
if ($this->ronly) $x->set('ronly',$this->ronly);
if ($this->disabl) $x->set('disabl',$this->disabl);
if ($this->name):
if ($type=='checkbox') $x->set('name',$this->name.'[]');
else $x->set('name',$this->name);
endif;
$x->set('label',$opt['label']);
$x->set('inValue',$opt['value']);
$x->set('value',$this->value);
return $x;
}
protected function putElementStd_light() {
$gen = '';
if ($this->id):
$tmp = htmlspecialchars($this->id);
$gen.= " id='$tmp'";
endif;
if ($this->cls):
$tmp = htmlspecialchars($this->cls);
$gen.= " class='$tmp'";
endif;
return $gen;
}
}
?>