-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
radiobutton.php
35 lines (32 loc) · 990 Bytes
/
radiobutton.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
<?php
class DingesRadioButton extends DingesMultiInputField {
protected $realLabelTag = false;
function validate($value) {
$valid = parent::validate($value);
if($valid !== true) {
return $valid;
}
if($value !== NULL && !isset($this->items[$value])) {
return 'ERR_UNKNOWN_OPTION';
}
return true;
}
function render() {
$this->fillAttributes();
$this->fillLabelAttributes();
$value = $this->getEffectiveValue();
$strings = array();
foreach($this->items as $item) {
$strings['element_'. $this->name .'_'. $item['value']] = $this->generateItemHTML($item, $value == $item['value']);
$strings['label_'. $this->name .'_'. $item['value']] = $this->getItemLabelTag($item);
}
$strings['label_'. $this->name] = $this->getLabelTag();
$strings['error_'. $this->name] = $this->generateErrorElement();
return $strings;
}
function fillAttributes() {
parent::fillAttributes();
$this->setAttribute('type', 'radio');
}
}
?>