Skip to content

Commit 4956b2a

Browse files
author
Sergey Semenov
committed
MAGETWO-47376: Number of address lines (street lines) in admin #2450
1 parent f93f18f commit 4956b2a

File tree

3 files changed

+96
-35
lines changed

3 files changed

+96
-35
lines changed

app/code/Magento/Customer/view/base/ui_component/customer_form.xml

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -343,41 +343,6 @@
343343
</item>
344344
</argument>
345345
</field>
346-
<container name="street_container">
347-
<argument name="data" xsi:type="array">
348-
<item name="type" xsi:type="string">group</item>
349-
<item name="config" xsi:type="array">
350-
<item name="component" xsi:type="string">Magento_Ui/js/form/components/group</item>
351-
<item name="label" xsi:type="string" translate="true">Street Address</item>
352-
<item name="required" xsi:type="boolean">true</item>
353-
<item name="dataScope" xsi:type="string">street</item>
354-
<item name="sortOrder" xsi:type="string">45</item>
355-
</item>
356-
</argument>
357-
<field name="street">
358-
<argument name="data" xsi:type="array">
359-
<item name="config" xsi:type="array">
360-
<item name="dataScope" xsi:type="string">0</item>
361-
<item name="dataType" xsi:type="string">text</item>
362-
<item name="formElement" xsi:type="string">input</item>
363-
<item name="source" xsi:type="string">address</item>
364-
<item name="validation" xsi:type="array">
365-
<item name="required-entry" xsi:type="boolean">true</item>
366-
</item>
367-
</item>
368-
</argument>
369-
</field>
370-
<field name="street_second">
371-
<argument name="data" xsi:type="array">
372-
<item name="config" xsi:type="array">
373-
<item name="dataScope" xsi:type="string">1</item>
374-
<item name="dataType" xsi:type="string">text</item>
375-
<item name="formElement" xsi:type="string">input</item>
376-
<item name="source" xsi:type="string">address</item>
377-
</item>
378-
</argument>
379-
</field>
380-
</container>
381346
<field name="city">
382347
<argument name="data" xsi:type="array">
383348
<item name="config" xsi:type="array">

lib/internal/Magento/Framework/Data/Form/Element/Multiline.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,4 +149,20 @@ public function getDefaultHtml()
149149
}
150150
return $html;
151151
}
152+
153+
/**
154+
* {@inheritdoc}
155+
*/
156+
public function getEscapedValue($index = null)
157+
{
158+
$value = $this->getValue();
159+
if (is_string($value)) {
160+
$value = explode("\n", $value);
161+
if (is_array($value)) {
162+
$this->setValue($value);
163+
}
164+
}
165+
166+
return parent::getEscapedValue($index);
167+
}
152168
}
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Framework\Data\Test\Unit\Form\Element;
7+
8+
class MultilineTest extends \PHPUnit_Framework_TestCase
9+
{
10+
/**
11+
* @var \Magento\Framework\Data\Form\Element\Multiline
12+
*/
13+
protected $element;
14+
15+
/**
16+
* @var \Magento\Framework\Data\Form\Element\Factory|\PHPUnit_Framework_MockObject_MockObject
17+
*/
18+
protected $elementFactory;
19+
20+
/**
21+
* @var \Magento\Framework\Data\Form\Element\CollectionFactory|\PHPUnit_Framework_MockObject_MockObject
22+
*/
23+
protected $collectionFactory;
24+
25+
/**
26+
* @var \Magento\Framework\Escaper|\PHPUnit_Framework_MockObject_MockObject
27+
*/
28+
protected $escaper;
29+
30+
protected function setUp()
31+
{
32+
$this->elementFactory = $this->getMockBuilder('Magento\Framework\Data\Form\Element\Factory')
33+
->disableOriginalConstructor()
34+
->getMock();
35+
36+
$this->collectionFactory = $this->getMockBuilder('Magento\Framework\Data\Form\Element\CollectionFactory')
37+
->disableOriginalConstructor()
38+
->getMock();
39+
40+
$this->escaper = $this->getMockBuilder('Magento\Framework\Escaper')
41+
->disableOriginalConstructor()
42+
->getMock();
43+
44+
$this->element = new \Magento\Framework\Data\Form\Element\Multiline(
45+
$this->elementFactory,
46+
$this->collectionFactory,
47+
$this->escaper
48+
);
49+
}
50+
51+
/**
52+
* @param mixed $value
53+
* @param int $index
54+
* @param string $resultValue
55+
* @return void
56+
* @dataProvider dataProviderValues
57+
*/
58+
public function testGetEscapedValue($value, $index, $resultValue)
59+
{
60+
$this->element->setValue($value);
61+
62+
$result = $this->element->getEscapedValue($index);
63+
$this->assertEquals($resultValue, $result);
64+
}
65+
66+
/**
67+
* @return array
68+
*/
69+
public function dataProviderValues()
70+
{
71+
return [
72+
["", 0, ""],
73+
["string1", 0, "string1"],
74+
["string1\nstring2", 0, "string1"],
75+
["string1\nstring2", 1, "string2"],
76+
["string1\nstring2", 2, null],
77+
[null, 0, null],
78+
];
79+
}
80+
}

0 commit comments

Comments
 (0)