Magento Extensions Rating 2024
EXTENSIONS BY CATEGORY
B2B (Business-To-Business)
Blog
Customer
ERP (Enterprise Resource Planning)
Mega Menu
One Step Checkout
Order
POS (Point Of Sale)
Search
Shopping Cart
Sitemap
SEO
Social
Stock & Inventory Management
EXTENSIONS BY DEVELOPER
aheadWorks
Amasty
Boost My Shop
BSS Commerce
Magestore
MageWorx
Mirasvit
Templates Master
Wyomind
XTENTO
Magento 2 Documentation
Magento 2 Documentation
2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
vendor
magento
module-customer
Model
Metadata
Form
Select.php
Go to the documentation of this file.
1
<?php
8
namespace
Magento\Customer\Model\Metadata\Form
;
9
10
use
Magento\Customer\Model\Metadata\ElementFactory
;
11
use
Magento\Framework\App\RequestInterface
;
12
13
class
Select
extends
AbstractData
14
{
18
public
function
extractValue
(
RequestInterface
$request
)
19
{
20
return
$this->
_getRequestValue
($request);
21
}
22
26
public
function
validateValue
(
$value
)
27
{
28
$errors
= [];
29
$attribute
= $this->
getAttribute
();
30
$label
=
__
(
$attribute
->getStoreLabel());
31
32
if
(
$value
===
false
) {
33
// try to load original value and validate it
34
$value
=
$this->_value
;
35
}
36
37
if
(
$attribute
->isRequired() && empty(
$value
) &&
$value
!==
'0'
) {
38
$errors
[] =
__
(
'"%1" is a required value.'
,
$label
);
39
}
40
41
if
(!
$errors
&& !
$attribute
->isRequired() && empty(
$value
)) {
42
return
true
;
43
}
44
45
if
(count(
$errors
) == 0) {
46
return
true
;
47
}
48
49
return
$errors
;
50
}
51
55
public
function
compactValue
(
$value
)
56
{
57
return
$value
;
58
}
59
63
public
function
restoreValue
(
$value
)
64
{
65
return
$this->
compactValue
(
$value
);
66
}
67
74
protected
function
_getOptionText
(
$value
)
75
{
76
foreach
($this->
getAttribute
()->getOptions() as
$option
) {
77
if
(
$option
->getValue() ==
$value
&& !is_bool(
$value
)) {
78
return
$option
->getLabel();
79
}
80
}
81
return
''
;
82
}
83
90
public
function
outputValue
(
$format
=
ElementFactory::OUTPUT_FORMAT_TEXT
)
91
{
92
$value
=
$this->_value
;
93
if
(
$format
===
ElementFactory::OUTPUT_FORMAT_JSON
) {
94
$output
=
$value
;
95
}
elseif
(
$value
!=
''
) {
96
$output
= $this->
_getOptionText
(
$value
);
97
}
else
{
98
$output
=
''
;
99
}
100
101
return
$output
;
102
}
103
}
Magento\Customer\Model\Metadata\Form\Select\extractValue
extractValue(RequestInterface $request)
Definition:
Select.php:18
Magento\Customer\Model\Metadata\ElementFactory
Definition:
ElementFactory.php:12
Magento\Customer\Model\Metadata\Form\Select\compactValue
compactValue($value)
Definition:
Select.php:55
elseif
elseif(isset( $params[ 'redirect_parent']))
Definition:
iframe.phtml:17
Magento\Customer\Model\Metadata\ElementFactory\OUTPUT_FORMAT_JSON
const OUTPUT_FORMAT_JSON
Definition:
ElementFactory.php:14
Magento\Customer\Model\Metadata\Form\Select\_getOptionText
_getOptionText($value)
Definition:
Select.php:74
$attribute
$attribute
Definition:
attribute_set_with_image_attribute.php:41
Magento\Customer\Model\Metadata\Form\AbstractData
Definition:
AbstractData.php:17
__
__()
Definition:
__.php:13
Magento\Customer\Model\Metadata\Form\AbstractData\_getRequestValue
_getRequestValue(\Magento\Framework\App\RequestInterface $request)
Definition:
AbstractData.php:458
Magento\Customer\Model\Metadata\Form\Select\restoreValue
restoreValue($value)
Definition:
Select.php:63
$label
$label
Definition:
details.phtml:21
$value
$value
Definition:
gender.phtml:16
$format
$format
Definition:
list.phtml:12
Magento\Framework\App\RequestInterface
Definition:
RequestInterface.php:14
Magento\Customer\Model\Metadata\Form\Select
Definition:
Select.php:13
$output
$output
Definition:
classmap_generator.php:100
$request
$request
Definition:
quote_with_configurable_product_last_variation.php:22
Magento\Customer\Model\Metadata\Form\Select\validateValue
validateValue($value)
Definition:
Select.php:26
Magento\Customer\Model\Metadata\Form
Definition:
AbstractData.php:9
Magento\Customer\Model\Metadata\ElementFactory\OUTPUT_FORMAT_TEXT
const OUTPUT_FORMAT_TEXT
Definition:
ElementFactory.php:15
Magento\Customer\Model\Metadata\Form\AbstractData\$_value
$_value
Definition:
AbstractData.php:78
$errors
$errors
Definition:
overview.phtml:9
$option
$option
Definition:
product_configurable_with_single_child.php:38
Magento\Customer\Model\Metadata\Form\AbstractData\getAttribute
getAttribute()
Definition:
AbstractData.php:118
Magento\Customer\Model\Metadata\Form\Select\outputValue
outputValue($format=ElementFactory::OUTPUT_FORMAT_TEXT)
Definition:
Select.php:90