1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Part of the Joomla Framework Form Package |
4
|
|
|
* |
5
|
|
|
* @copyright Copyright (C) 2005 - 2016 Open Source Matters, Inc. All rights reserved. |
6
|
|
|
* @license GNU General Public License version 2 or later; see LICENSE |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
namespace Joomla\Form; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* Form Field class for the Joomla Framework. |
13
|
|
|
* Single check box field. |
14
|
|
|
* This is a boolean field with null for false and the specified option for true |
15
|
|
|
* |
16
|
|
|
* @link http://www.w3.org/TR/html-markup/input.checkbox.html#input.checkbox |
17
|
|
|
* @see JFormFieldCheckboxes |
18
|
|
|
* @since 1.0 |
19
|
|
|
* @deprecated The joomla/form package is deprecated |
20
|
|
|
*/ |
21
|
|
|
class Field_Checkbox extends Field |
|
|
|
|
22
|
|
|
{ |
23
|
|
|
/** |
24
|
|
|
* The form field type. |
25
|
|
|
* |
26
|
|
|
* @var string |
27
|
|
|
* @since 1.0 |
28
|
|
|
*/ |
29
|
|
|
public $type = 'Checkbox'; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Method to get the field input markup. |
33
|
|
|
* The checked element sets the field to selected. |
34
|
|
|
* |
35
|
|
|
* @return string The field input markup. |
36
|
|
|
* |
37
|
|
|
* @since 1.0 |
38
|
|
|
*/ |
39
|
|
|
protected function getInput() |
40
|
|
|
{ |
41
|
|
|
// Initialize some field attributes. |
42
|
|
|
$class = $this->element['class'] ? ' class="' . (string) $this->element['class'] . '"' : ''; |
43
|
|
|
$disabled = ((string) $this->element['disabled'] == 'true') ? ' disabled="disabled"' : ''; |
44
|
|
|
$value = $this->element['value'] ? (string) $this->element['value'] : '1'; |
45
|
|
|
|
46
|
|
|
if (empty($this->value)) |
47
|
|
|
{ |
48
|
|
|
$checked = (isset($this->element['checked'] )) ? ' checked="checked"' : ''; |
49
|
|
|
} |
50
|
|
|
else |
51
|
|
|
{ |
52
|
|
|
$checked = ' checked="checked"'; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
// Initialize JavaScript field attributes. |
56
|
|
|
$onclick = $this->element['onclick'] ? ' onclick="' . (string) $this->element['onclick'] . '"' : ''; |
57
|
|
|
|
58
|
|
|
return '<input type="checkbox" name="' . $this->name . '" id="' . $this->id . '"' . ' value="' |
59
|
|
|
. htmlspecialchars($value, ENT_COMPAT, 'UTF-8') . '"' . $class . $checked . $disabled . $onclick . ' />'; |
60
|
|
|
} |
61
|
|
|
} |
62
|
|
|
|
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.