/
multiinputfield.php
53 lines (44 loc) · 1.48 KB
/
multiinputfield.php
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
<?php
abstract class DingesMultiInputField extends DingesInputField {
protected $realLabelTag = false;
protected $itemLabelAttributes = array();
protected $items = array();
function addItem($value, $content, $escape_html = true) {
if($escape_html) {
$content = htmlspecialchars($content, ENT_NOQUOTES, NULL, false);
}
$this->items[$value] = array('value' => $value, 'content' => $content);
}
function setItemLabelAttribute($name, $value, $append = false) {
if($append && isset($this->itemLabelAttributes[$name])) {
$this->itemLabelAttributes[$name] .= $value;
} else {
$this->itemLabelAttributes[$name] = $value;
}
}
function deleteItemLabelAttribute($name) {
unset($this->itemLabelAttributes[$name]);
}
function getItemLabelAttribute($name) {
return $this->itemLabelAttributes[$name];
}
function getItemLabelTag($item) {
$attributes = $this->itemLabelAttributes;
$attributes['id'] = $this->getFullLabelId() .'_'. $item['value'];
$attributes['for'] = $this->getFullId() .'_'. $item['value'];
return DingesForm::generateTag('label', $attributes, $item['content']);
}
function generateItemHTML($item, $checked) {
$attributes = $this->attributes;
$attributes['id'] = $this->getFullId() .'_'. $item['value'];
$attributes['value'] = $item['value'];
if($checked) {
$attributes['checked'] = 'checked';
}
return DingesForm::generateTag('input', $attributes);
}
function getFormInitCode() {
return '';
}
}
?>