Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
select.php
1
<?php
2
namespace
Bitrix\Landing\Field
;
3
4
use \Bitrix\Main\Localization\Loc;
5
6
Loc::loadMessages
(__FILE__);
7
8
class
Select
extends
\Bitrix\Landing\Field
9
{
14
protected
$options
= array();
15
20
protected
$multiple
=
false
;
21
27
public
function
__construct
(
$code
, array $params = array())
28
{
29
$this->code = mb_strtoupper(
$code
);
30
$this->value =
null
;
31
$this->
default
= isset($params[
'default'
]) ? $params[
'default'
] :
null
;
32
$this->
id
= isset($params[
'id'
]) ? $params[
'id'
] :
''
;
33
$this->title = isset($params[
'title'
]) ? $params[
'title'
] :
''
;
34
$this->multiple = isset($params[
'multiple'
]) && $params[
'multiple'
];
35
$this->help = isset($params[
'help'
]) ? $params[
'help'
] :
''
;
36
$this->htmlHelp = isset($params[
'htmlHelp'
]) ? $params[
'htmlHelp'
] :
''
;
37
$this->options = isset($params[
'options'
]) ? (array)$params[
'options'
] : array();
38
}
39
44
public
function
isEmptyValue
()
45
{
46
return
$this->value ===
''
||
47
$this->value === 0;
48
}
49
54
public
function
isMulti
()
55
{
56
return
$this->multiple
;
57
}
58
67
public
function
viewForm
(array $params = array())
68
{
69
?>
70
<select <?php
71
?><?= isset($params[
'additional'
]) ? $params[
'additional'
] .
' '
:
''
?><?php
72
?><?= isset($params[
'id'
]) ?
'id="'
. \htmlspecialcharsbx($params[
'id'
]) .
'" '
:
''
?><?php
73
?><?= $this->multiple ?
'multiple="multiple" size="3" '
:
''
?><?php
74
?>
class
=
"<?= isset($params['class']) ? \htmlspecialcharsbx($params['class']) : ''?>"
<?php
75
?>name=
"<?= $this->getName($params["
name_format
"])?><?= $this->multiple ? '[]' : ''?>"
<?php
76
?> />
77
<?
foreach
($this->options as
$code
=> $val):?>
78
<option value=
"<?= \htmlspecialcharsbx($code)?>"
<?php
79
echo in_array(
$code
, (array) $this->value) ?
' selected="selected"'
:
''
;
80
if
(!$this->value &&
$code
== $this->
default
)
81
{
82
echo
' selected="selected"'
;
83
}
84
?>>
85
<?= \htmlspecialcharsbx($val)?>
86
</option>
87
<?php endforeach;?>
88
</select>
89
<?php
90
}
91
97
public
function
getName
($nameFormat)
98
{
99
return \htmlspecialcharsbx(isset($nameFormat)
100
? str_replace(
'#field_code#'
, $this->code, $nameFormat)
101
:
$this->code
);
102
}
103
108
public
function
getOptions
()
109
{
110
return
$this->options
;
111
}
112
}
Bitrix\Landing\Field\Select
Definition
select.php:9
Bitrix\Landing\Field\Select\$options
$options
Definition
select.php:14
Bitrix\Landing\Field\Select\getName
getName($nameFormat)
Definition
select.php:97
Bitrix\Landing\Field\Select\$multiple
$multiple
Definition
select.php:20
Bitrix\Landing\Field\Select\getOptions
getOptions()
Definition
select.php:108
Bitrix\Landing\Field\Select\__construct
__construct($code, array $params=array())
Definition
select.php:27
Bitrix\Landing\Field\Select\isEmptyValue
isEmptyValue()
Definition
select.php:44
Bitrix\Landing\Field\Select\viewForm
viewForm(array $params=array())
Definition
select.php:67
Bitrix\Landing\Field\Select\isMulti
isMulti()
Definition
select.php:54
Bitrix\Landing\Field
Definition
field.php:5
Bitrix\Landing\Field\$code
$code
Definition
field.php:16
Bitrix\Main\Localization\Loc\loadMessages
static loadMessages($file)
Definition
loc.php:64
Bitrix\Landing\Field
Definition
checkbox.php:2
modules
landing
lib
field
select.php
Создано системой
1.10.0