Open Journal Systems
3.3.0
FormValidatorBoolean.inc.php
1
<?php
2
18
import
(
'lib.pkp.classes.form.validation.FormValidator'
);
19
20
class
FormValidatorBoolean
extends
FormValidator
{
27
function
__construct
(&$form, $field, $message) {
28
parent::__construct($form, $field, FORM_VALIDATOR_OPTIONAL_VALUE, $message);
29
}
30
31
32
//
33
// Public methods
34
//
42
function
isValid
() {
43
$value = $this->
getFieldValue
();
44
$form =& $this->
getForm
();
45
if
(empty($value) || $value ==
'on'
) {
46
// Make sure that the form will contain a real
47
// boolean value after validation.
48
$value = ($value ==
'on'
? true :
false
);
49
$form->setData($this->
getField
(), $value);
50
return
true
;
51
} elseif($value ===
'1'
|| $value ===
'0'
) {
52
$value = ($value ===
'1'
? true :
false
);
53
$form->setData($this->
getField
(), $value);
54
return
true
;
55
}
else
{
56
return
false
;
57
}
58
}
59
}
60
61
FormValidatorBoolean\isValid
isValid()
Definition:
FormValidatorBoolean.inc.php:42
FormValidator\getField
getField()
Definition:
FormValidator.inc.php:84
FormValidator\getForm
& getForm()
Definition:
FormValidator.inc.php:100
FormValidatorBoolean
Form validation check that checks if the value can be interpreted as a boolean value....
Definition:
FormValidatorBoolean.inc.php:20
FormValidator
Class to represent a form validation check.
Definition:
FormValidator.inc.php:23
FormValidatorBoolean\__construct
__construct(&$form, $field, $message)
Definition:
FormValidatorBoolean.inc.php:27
FormValidator\getFieldValue
getFieldValue()
Definition:
FormValidator.inc.php:154
lib
pkp
classes
form
validation
FormValidatorBoolean.inc.php
Generated on Fri Aug 28 2020 14:51:56 for Open Journal Systems by
1.8.17