MIOLO20
Carregando...
Procurando...
Nenhuma entrada encontrada
mformcontrol.class
Ir para a documentação deste ficheiro.
1
<?php
2
3
class
MFormControl
extends
MControl
4
{
5
public
$label
;
6
public
$value
;
7
public
$hint
;
8
13
public
$form
;
14
15
public
$formName
;
16
public
$showLabel
;
// se label deve ser exibido junto com o campo
17
public
$autoPostBack
;
18
public
$forceShowLabel
=
false
;
19
23
public
$isRequired
;
24
29
private
$addedValidator;
30
31
public
$autoSetRequired
=
true
;
32
33
public
function
__construct
(
$name
,
$value
=
''
,
$label
=
''
, $color =
''
,
$hint
=
''
)
34
{
35
parent::__construct(
$name
);
36
37
$this->
addStyleFile
(
'm_controls.css'
);
38
$this->
setValue
(
$value
);
39
$this->label =
$label
;
40
$this->hint =
$hint
;
41
42
if
( $color !=
''
)
43
{
44
$this->color = $color;
45
}
46
47
$this->showLabel =
true
;
48
$this->autoPostBack =
false
;
49
$this->form = NULL;
50
}
51
52
53
public
function
setValue
(
$value
)
54
{
55
$this->value =
$value
;
56
}
57
58
59
public
function
getValue
()
60
{
61
return
$this->value
;
62
}
63
64
65
public
function
setLabel
(
$label
)
66
{
67
$this->label =
$label
;
68
}
69
70
71
public
function
setAutoPostBack
(
$value
)
72
{
73
$this->autoPostBack =
$value
;
74
}
75
76
function
setAutoSubmit
( $isAuto =
true
)
77
{
78
$this->autoPostBack = $isAuto;
79
}
80
81
public
function
getIsRequired
()
82
{
83
return
$this->isRequired
;
84
}
85
91
public
function
setIsRequired
(
$isRequired
)
92
{
93
$this->isRequired =
$isRequired
;
94
95
if
(
$isRequired
)
96
{
97
$this->addFieldValidator();
98
}
99
100
return
$this;
101
}
102
109
public
function
getRequiredType
()
110
{
111
return
$this->
getIsRequired
() ?
'required'
:
'optional'
;
112
}
113
114
private
function
addFieldValidator()
115
{
116
if
( $this->
getFieldForm
() instanceof
MForm
&& !$this->addedValidator )
117
{
118
$this->
getFieldForm
()->AddValidator(
new
MRequiredValidator
($this->name, $this->label, $this->
getRequiredType
()) );
119
120
$this->addedValidator =
true
;
121
}
122
}
123
128
public
function
getFieldForm
()
129
{
130
return
$this->form
;
131
}
132
138
public
function
setFieldForm
(
MForm
$form
)
139
{
140
$this->form =
$form
;
141
142
if
( $this->
getIsRequired
() )
143
{
144
$this->addFieldValidator();
145
}
146
}
147
148
public
function
generateLabel
()
149
{
150
$label
=
''
;
151
$this->showLabel = ( $this->formMode >=
MControl::FORM_MODE_SHOW_ABOVE
);
152
153
if
( ( $this->showLabel ) && ( $this->label !=
''
) )
154
{
155
$fieldLabel =
new
MFieldLabel
($this->
id
, $this->label);
156
$fieldLabel->setClass(
MControl::CLASS_CAPTION
);
157
158
if
( ! $this->validator && method_exists($this->form,
'getFieldValidator'
) )
159
{
160
$this->validator = $this->form->getFieldValidator($this->name);
161
}
162
163
$r = $this->attrs->items[
'required'
] || ($this->validator && $this->validator->type ==
'required'
);
164
165
if
( $r && trim(
MUtil::removeSpaceChars
($this->label)) )
166
{
167
$fieldLabel->setClass(
MControl::CLASS_CAPTION_REQUIRED
);
168
}
169
170
$label
= $this->painter->label( $fieldLabel );
171
172
if
( $this->formMode ==
MControl::FORM_MODE_SHOW_NBSP
)
173
{
174
$label
.=
" "
;
175
}
176
}
177
178
return
$label
;
179
}
180
181
}
182
?>
MComponent\$name
$name
Definição
mcomponent.class:17
MControl
Definição
mcontrol.class:35
MControl\FORM_MODE_SHOW_NBSP
const FORM_MODE_SHOW_NBSP
Definição
mcontrol.class:44
MControl\CLASS_CAPTION
const CLASS_CAPTION
Definição
mcontrol.class:46
MControl\addStyleFile
addStyleFile( $styleFile)
Definição
mcontrol.class:412
MControl\CLASS_CAPTION_REQUIRED
const CLASS_CAPTION_REQUIRED
Definição
mcontrol.class:47
MControl\FORM_MODE_SHOW_ABOVE
const FORM_MODE_SHOW_ABOVE
Definição
mcontrol.class:43
MFieldLabel
Definição
labelcontrols.class:128
MFormControl
Definição
mformcontrol.class:4
MFormControl\$autoSetRequired
$autoSetRequired
Definição
mformcontrol.class:31
MFormControl\$isRequired
$isRequired
Definição
mformcontrol.class:23
MFormControl\$value
$value
Definição
mformcontrol.class:6
MFormControl\$formName
$formName
Definição
mformcontrol.class:15
MFormControl\$label
$label
Definição
mformcontrol.class:5
MFormControl\$form
$form
Definição
mformcontrol.class:13
MFormControl\setIsRequired
setIsRequired($isRequired)
Definição
mformcontrol.class:91
MFormControl\getFieldForm
getFieldForm()
Definição
mformcontrol.class:128
MFormControl\$autoPostBack
$autoPostBack
Definição
mformcontrol.class:17
MFormControl\setAutoSubmit
setAutoSubmit( $isAuto=true)
Definição
mformcontrol.class:76
MFormControl\$forceShowLabel
$forceShowLabel
Definição
mformcontrol.class:18
MFormControl\generateLabel
generateLabel()
Definição
mformcontrol.class:148
MFormControl\getRequiredType
getRequiredType()
Definição
mformcontrol.class:109
MFormControl\$showLabel
$showLabel
Definição
mformcontrol.class:16
MFormControl\setAutoPostBack
setAutoPostBack( $value)
Definição
mformcontrol.class:71
MFormControl\setLabel
setLabel( $label)
Definição
mformcontrol.class:65
MFormControl\getValue
getValue()
Definição
mformcontrol.class:59
MFormControl\setFieldForm
setFieldForm(MForm $form)
Definição
mformcontrol.class:138
MFormControl\__construct
__construct( $name, $value='', $label='', $color='', $hint='')
Definição
mformcontrol.class:33
MFormControl\$hint
$hint
Definição
mformcontrol.class:7
MFormControl\setValue
setValue( $value)
Definição
mformcontrol.class:53
MFormControl\getIsRequired
getIsRequired()
Definição
mformcontrol.class:81
MForm
Definição
mform.class:9
MRequiredValidator
Definição
mvalidator.class:114
MUtil\removeSpaceChars
static removeSpaceChars($value)
Definição
mutil.class:117
classes
ui
controls
mformcontrol.class
Gerado por
1.10.0