Completed
Push — master ( 012895...9e0835 )
by Jean-Christophe
03:33
created

AbstractHtmlFormRadioCheckbox::setReadonly()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
namespace Ajax\semantic\html\collections\form;
4
5
use Ajax\semantic\html\collections\form\HtmlFormInput;
6
use Ajax\semantic\html\base\constants\CheckboxType;
7
/**
8
 * Abstract class for Semantic Radio and Checkbox
9
 * @author jc
10
 * @version 1.001
11
 */
12
abstract class AbstractHtmlFormRadioCheckbox extends HtmlFormField {
13
	protected $_input;
14
15
	public function __construct($identifier, $name=NULL,$label=NULL,$value=NULL,$type=NULL) {
16
		$input=new HtmlFormInput($identifier,$label,"checkbox",$value);
17
		parent::__construct("rField-".$identifier, $input);
18
		if(isset($label)){
19
			$input->swapLabel();
20
			$label=$input->getLabel();
21
			$label->setClass="hidden";
22
			$label->setProperty("tabindex",0);
23
		}
24
		$this->_input=$input;
25
		$input->getField()->addToProperty("class","hidden");
26
	}
27
28
	public function setType($checkboxType){
29
		return $this->_input->addToPropertyCtrl("class", $checkboxType, CheckboxType::getConstants());
30
	}
31
32
	public function getInput() {
33
		return $this->_input;
34
	}
35
36
	public function setInput($_input) {
37
		$this->_input=$_input;
38
		return $this;
39
	}
40
41
	public function setReadonly(){
42
		$this->_input->getField()->setProperty("disabled","disabled");
43
		return $this->_input->addToProperty("class","read-only");
44
	}
45
46
}