Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
text.php
1
<?php
2
namespace
Bitrix\Landing\Field
;
3
4
class
Text
extends
\Bitrix\Landing\Field
5
{
10
protected
$maxlength
;
11
16
protected
$placeholder
;
17
23
public
function
__construct
(
$code
, array $params = array())
24
{
25
$this->code = mb_strtoupper(
$code
);
26
$this->value =
null
;
27
$this->
id
= isset($params[
'id'
]) ? $params[
'id'
] :
''
;
28
$this->title = isset($params[
'title'
]) ? $params[
'title'
] :
''
;
29
$this->
default
= isset($params[
'default'
]) ? $params[
'default'
] :
null
;
30
$this->help = isset($params[
'help'
]) ? $params[
'help'
] :
''
;
31
$this->searchable = isset($params[
'searchable'
]) && $params[
'searchable'
] ===
true
;
32
$this->placeholder = isset($params[
'placeholder'
]) ? $params[
'placeholder'
] :
''
;
33
$this->maxlength = isset($params[
'maxlength'
]) ? (int)$params[
'maxlength'
] : 0;
34
}
35
40
public
function
isEmptyValue
()
41
{
42
return
$this->value ===
''
;
43
}
44
53
public
function
viewForm
(array $params = array())
54
{
55
?>
56
<input type=
"text"
<?
57
?><?= isset($params[
'autocomplete'
]) ?
'autocomplete="'
. $params[
'autocomplete'
] .
'" '
:
''
?><?
58
?><?= isset($params[
'additional'
]) ? $params[
'additional'
] .
' '
:
''
?><?
59
?><?= isset($params[
'id'
]) ?
'id="'
. \htmlspecialcharsbx($params[
'id'
]) .
'" '
:
''
?><?
60
?><?= $this->maxlength > 0 ?
'maxlength="'
. $this->maxlength .
'" '
:
''
?><?
61
?><?= $this->placeholder !=
''
?
'placeholder="'
. \htmlspecialcharsbx($this->placeholder) .
'" '
:
''
?><?
62
?>
class
=
"<?= isset($params['class']) ? \htmlspecialcharsbx($params['class']) : ''?>"
<?
63
?>data-code=
"<?= \htmlspecialcharsbx($this->code)?>"
<?
64
?>name=
"<?= \htmlspecialcharsbx(isset($params['name_format'])
65
? str_replace('#field_code#', $this->code, $params['name_format'])
66
: $this->code)?>"
<?
67
?><?= (isset($params[
'disabled'
]) && $params[
'disabled'
]) ?
' disabled '
:
''
?><?
68
?><?= (isset($params[
'readonly'
]) && $params[
'readonly'
]) ?
' readonly '
:
''
?><?
69
?>value=
"<?= \htmlspecialcharsbx($this->value ? $this->value : $this->default)?>"
<?
70
?> />
71
<?
72
}
73
79
public
function
setValue
(
$value
)
80
{
81
if
($this->maxlength > 0)
82
{
83
$this->value = mb_substr(
$value
, 0, $this->maxlength);
84
}
85
else
86
{
87
$this->value =
$value
;
88
}
89
}
90
}
Bitrix\Landing\Field\Text
Definition
text.php:5
Bitrix\Landing\Field\Text\__construct
__construct($code, array $params=array())
Definition
text.php:23
Bitrix\Landing\Field\Text\setValue
setValue($value)
Definition
text.php:79
Bitrix\Landing\Field\Text\isEmptyValue
isEmptyValue()
Definition
text.php:40
Bitrix\Landing\Field\Text\viewForm
viewForm(array $params=array())
Definition
text.php:53
Bitrix\Landing\Field\Text\$placeholder
$placeholder
Definition
text.php:16
Bitrix\Landing\Field\Text\$maxlength
$maxlength
Definition
text.php:10
Bitrix\Landing\Field
Definition
field.php:5
Bitrix\Landing\Field\$value
$value
Definition
field.php:22
Bitrix\Landing\Field\$code
$code
Definition
field.php:16
Bitrix\Landing\Field
Definition
checkbox.php:2
modules
landing
lib
field
text.php
Создано системой
1.10.0