File tree Expand file tree Collapse file tree 4 files changed +25
-6
lines changed
Ui/Component/Form/Element
dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/form/components Expand file tree Collapse file tree 4 files changed +25
-6
lines changed Original file line number Diff line number Diff line change 17
17
use Magento \Framework \Session \SessionManagerInterface ;
18
18
use Magento \Customer \Model \FileUploaderDataResolver ;
19
19
use Magento \Customer \Model \AttributeMetadataResolver ;
20
+ use Magento \Ui \Component \Form \Element \Multiline ;
20
21
use Magento \Ui \DataProvider \AbstractDataProvider ;
21
22
22
23
/**
@@ -130,6 +131,7 @@ public function getData(): array
130
131
$ result ['customer ' ],
131
132
array_flip (self ::$ forbiddenCustomerFields )
132
133
);
134
+ $ this ->prepareCustomAttributeValue ($ result ['customer ' ]);
133
135
unset($ result ['address ' ]);
134
136
135
137
$ result ['default_billing_address ' ] = $ this ->prepareDefaultAddress (
@@ -179,6 +181,24 @@ private function prepareDefaultAddress($address): array
179
181
return $ addressData ;
180
182
}
181
183
184
+ /***
185
+ * Prepare values for Custom Attributes.
186
+ *
187
+ * @param array $data
188
+ * @return void
189
+ */
190
+ private function prepareCustomAttributeValue (array &$ data ): void
191
+ {
192
+ foreach ($ this ->meta ['customer ' ]['children ' ] as $ attributeName => $ attributeMeta ) {
193
+ if ($ attributeMeta ['arguments ' ]['data ' ]['config ' ]['dataType ' ] === Multiline::NAME
194
+ && isset ($ data [$ attributeName ])
195
+ && !is_array ($ data [$ attributeName ])
196
+ ) {
197
+ $ data [$ attributeName ] = explode ("\n" , $ data [$ attributeName ]);
198
+ }
199
+ }
200
+ }
201
+
182
202
/**
183
203
* Get attributes meta
184
204
*
Original file line number Diff line number Diff line change @@ -78,7 +78,7 @@ public function validateValue($value)
78
78
public function compactValue ($ value )
79
79
{
80
80
if (is_array ($ value )) {
81
- $ value = implode ("\n" , $ value );
81
+ $ value = trim ( implode ("\n" , $ value) );
82
82
}
83
83
$ value = [$ value ];
84
84
Original file line number Diff line number Diff line change @@ -66,7 +66,6 @@ public function prepare()
66
66
{
67
67
$ size = abs ((int ) $ this ->getData ('config/size ' ));
68
68
$ validation = [$ this ->getData ('config/validation ' )];
69
- $ namespace = $ this ->getContext ()->getNamespace ();
70
69
while ($ size --) {
71
70
$ identifier = $ this ->getName () . '_ ' . $ size ;
72
71
$ arguments = [
@@ -75,8 +74,6 @@ public function prepare()
75
74
'config ' => [
76
75
'dataScope ' => $ size ,
77
76
'dataType ' => static ::DATA_TYPE ,
78
- 'deps ' => "{$ namespace }.areas.customer.customer. {$ this ->getName ()}" ,
79
- 'provider ' => $ namespace . '. ' . $ this ->getContext ()->getDataProvider ()->getName (),
80
77
'formElement ' => static ::FORM_ELEMENT ,
81
78
'sortOrder ' => $ size ,
82
79
]
Original file line number Diff line number Diff line change @@ -17,8 +17,10 @@ define([
17
17
registry . set ( providerName , {
18
18
/** Stub */
19
19
on : function ( ) { } ,
20
+
20
21
/** Stub */
21
22
set : function ( ) { } ,
23
+
22
24
/** Stub */
23
25
get : function ( ) {
24
26
return value ;
@@ -48,15 +50,15 @@ define([
48
50
} ) ;
49
51
50
52
it ( 'Check preparation of string value with line breaks' , function ( ) {
51
- var value = '\n222\n ' ;
53
+ var value = 'first\n\nthird ' ;
52
54
53
55
prepareDataProvider ( value ) ;
54
56
obj = new Constr ( {
55
57
provider : providerName ,
56
58
dataScope : dataScope
57
59
} ) ;
58
60
59
- expect ( obj . value ( ) ) . toEqual ( [ '' , '222 ' , '' ] ) ;
61
+ expect ( obj . value ( ) ) . toEqual ( [ 'first ' , '' , 'third ' ] ) ;
60
62
} ) ;
61
63
} ) ;
62
64
} ) ;
You can’t perform that action at this time.
0 commit comments