MIOLO20
Carregando...
Procurando...
Nenhuma entrada encontrada
choicecontrols.class
Ir para a documentação deste ficheiro.
1<?php
2
4{
5 public $checked;
6 public $text;
7 public $type;
8
9 public function __construct( $name = '', $value = '', $label = '', $checked = false, $text = NULL, $hint = '' )
10 {
11 parent::__construct( $name, $value, $label, '', $hint );
12
13 $this->checked = $checked;
14 $this->text = $text;
15 $this->formMode = 1;
16 }
17
18 public function setChecked( $checked )
19 {
20 if ( ! is_bool( $checked ) )
21 {
22 throw new Exception( _M('This method expects an boolean as parameter!') );
23 }
24
25 $this->checked = $checked;
26 }
27
28}
29
30
32{
33 function generateInner()
34 {
35 if ( $this->readonly )
36 {
37 return $this->text;
38 }
39
40 if ( $this->autoPostBack )
41 {
42 $this->addAttribute( 'onclick', "return _doPostBack('{$this->name}:click',''); document.{$this->page->name}.submit()" );
43 }
44
45 $this->setClass( 'm-checkbox-group' );
46 $this->type = 'checkbox';
47 $this->inner = $this->generateLabel() . $this->getRender( 'inputcheck' );
48 }
49}
50
51
53{
54 function generateInner()
55 {
56 if ( $this->readonly )
57 {
58 return $this->text;
59 }
60
61 if ( $this->autoPostBack )
62 {
63 $this->addAttribute( 'onclick', "document.{$this->page->name}.submit()" );
64 }
65
66 $this->setClass( 'm-radiobutton-group' );
67 $this->type = 'radio';
68 $this->inner = $this->generateLabel() . $this->getRender( 'inputcheck' );
69 }
70}
71
73{
74 private $radioLabels;
75 private $radioButtons;
76
86 public function __construct($name, $label = null, $options = array(), $checkedOption = null)
87 {
88 if (!is_null($label))
89 {
90 $fields[] = new MCaptionLabel($label);
91 }
92 foreach ($options as $valueRadio => $labelRadio)
93 {
94 $fields[] = $this->radioButtons[$valueRadio] = new MRadioButton($name, $valueRadio, null, ($checkedOption == $valueRadio));
95
96 // Quando clicar na label vai disparar o radio
97 $radioLabel = new MLabel("<strong>" . $labelRadio . "</strong>");
98 $radioLabel->addAttribute('onclick', "$('#".$name."[value=".$valueRadio."]').click();");
99 $fields[] = $this->radioLabels[] = $radioLabel;
100 }
101
102 parent::__construct('hct' . $name, $fields);
103
104 $this->setClass('m-radio-options');
105 }
106
107 public function getRadioLabels()
108 {
109 return $this->radioLabels;
110 }
111
112 public function setRadioLabels($radioLabels)
113 {
114 $this->radioLabels = $radioLabels;
115 }
116
117 public function getButtonByValue($value)
118 {
119 return $this->radioButtons[$value];
120 }
121
122 public function getRadioButtons()
123 {
124 return $this->radioButtons;
125 }
126
127 public function setRadioButtons($radioButtons)
128 {
129 $this->radioButtons = $radioButtons;
130 }
131}
132
133?>
__construct( $name='', $value='', $label='', $checked=false, $text=NULL, $hint='')
setChecked( $checked)
setClass($cssClass, $add=true)
setClass( $cssClass, $add=true)
Definição mcontrol.class:398
addAttribute( $name, $value='')
Definição mcontrol.class:443
getRender( $method)
Definição mcontrol.class:833
setRadioLabels($radioLabels)
getButtonByValue($value)
setRadioButtons($radioButtons)
__construct($name, $label=null, $options=array(), $checkedOption=null)