8000 Merge branch '5.2' into 5.x · symfony/symfony@bf30fa4 · GitHub
[go: up one dir, main page]

Skip to content

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit bf30fa4

Browse files
committed
Merge branch '5.2' into 5.x
* 5.2: [Form] Ignoring invalid forms from delete_empty behavior in CollectionType Add Symfony Armenian Translations cs fix Add different header notations to tests
2 parents 5cfe73d + 8cec0b6 commit bf30fa4

File tree

6 files changed

+163
-4
lines changed

6 files changed

+163
-4
lines changed

src/Symfony/Component/BrowserKit/Tests/HttpBrowserTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,18 @@ public function validContentTypes()
6363
['POST', 'http://example.com/', [], [], ['CONTENT_TYPE' => 'application/json'], '["content"]'],
6464
['POST', 'http://example.com/', ['headers' => $defaultHeaders + ['content-type' => 'application/json'], 'body' => '["content"]', 'max_redirects' => 0]],
6565
];
66+
yield 'custom header with HTTP_ prefix' => [
67+
['PUT', 'http://example.com/', [], [], ['HTTP_CONTENT_TYPE' => 'application/json'], '["content"]'],
68+
['PUT', 'http://example.com/', ['headers' => $defaultHeaders + ['content-type' => 'application/json'], 'body' => '["content"]', 'max_redirects' => 0]],
69+
];
70+
yield 'modify notation of custom header with HTTP_ prefix' => [
71+
['PUT', 'http://example.com/', [], [], ['HTTP_Content-Type' => 'application/json'], '["content"]'],
72+
['PUT', 'http://example.com/', ['headers' => $defaultHeaders + ['content-type' => 'application/json'], 'body' => '["content"]', 'max_redirects' => 0]],
73+
];
74+
yield 'modify notation of custom header' => [
75+
['PUT', 'http://example.com/', [], [], ['Content-Type' => 'application/json'], '["content"]'],
76+
['PUT', 'http://example.com/', ['headers' => $defaultHeaders + ['content-type' => 'application/json'], 'body' => '["content"]', 'max_redirects' => 0]],
77+
];
6678
yield 'GET JSON' => [
6779
['GET', 'http://example.com/jsonrpc', [], [], ['CONTENT_TYPE' => 'application/json'], '["content"]'],
6880
['GET', 'http://example.com/jsonrpc', ['headers' => $defaultHeaders + ['content-type' => 'application/json'], 'body' => '["content"]', 'max_redirects' => 0]],

src/Symfony/Component/DependencyInjection/Compiler/ResolveInstanceofConditionalsPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ private function processDefinition(ContainerBuilder $container, string $id, Defi
7373
$parent = $definition instanceof ChildDefinition ? $definition->getParent() : null;
7474

7575
foreach ($conditionals as $interface => $instanceofDefs) {
76-
if ($interface !== $class && !(null === $reflectionClass ? $reflectionClass = ($container->getReflectionClass($class, false) ?: false) : $reflectionClass)) {
76+
if ($interface !== $class && !($reflectionClass ?? $reflectionClass = $container->getReflectionClass($class, false) ?: false)) {
7777
continue;
7878
}
7979

src/Symfony/Component/Form/Extension/Core/EventListener/ResizeFormListener.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,10 @@ public function onSubmit(FormEvent $event)
132132
$previousData = $form->getData();
133133
/** @var FormInterface $child */
134134
foreach ($form as $name => $child) {
135+
if (!$child->isValid() || !$child->isSynchronized()) {
136+
continue;
137+
}
138+
135139
$isNew = !isset($previousData[$name]);
136140
$isEmpty = \is_callable($this->deleteEmpty) ? ($this->deleteEmpty)($child->getData()) : $child->isEmpty();
137141

src/Symfony/Component/Form/Resources/translations/validators.hy.xlf

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,126 @@
1414
<source>The CSRF token is invalid. Please try to resubmit the form.</source>
1515
<target>CSRF արժեքը անթույլատրելի է. Փորձեք նորից ուղարկել ձևը։</target>
1616
</trans-unit>
17+
<trans-unit id="99">
18+
<source>This value is not a valid HTML5 color.</source>
19+
<target>Այս արժեքը վավեր HTML5 գույն չէ։</target>
20+
</trans-unit>
21+
<trans-unit id="100">
22+
<source>Please enter a valid birthdate.</source>
23+
<target>Խնդրում ենք մուտքագրել վավեր ծննդյան ամսաթիվ։</target>
24+
</trans-unit>
25+
<trans-unit id="101">
26+
<source>The selected choice is invalid.</source>
27+
<target>Ընտրված ընտրությունն անվավեր է։</target>
28+
</trans-unit>
29+
<trans-unit id="102">
30+
<source>The collection is invalid.</source>
31+
<target>Համախումբն անվավեր է։</target>
32+
</trans-unit>
33+
<trans-unit id="103">
34+
<source>Please select a valid color.</source>
35+
<target>Խնդրում ենք ընտրել վավեր գույն։</target>
36+
</trans-unit>
37+
<trans-unit id="104">
38+
<source>Please select a valid country.</source>
39+
<target>Խնդրում ենք ընտրել վավեր երկիր։</target>
40+
</trans-unit>
41+
<trans-unit id="105">
42+
<source>Please select a valid currency.</source>
43+
<target>Խնդրում ենք ընտրել վավեր արժույթ։</target>
44+
</trans-unit>
45+
<trans-unit id="106">
46+
<source>Please choose a valid date interval.</source>
47+
<target>Խնդրում ենք ընտրել ճիշտ ամսաթվերի միջակայք։</target>
48+
</trans-unit>
49+
<trans-unit id="107">
50+
<source>Please enter a valid date and time.</source>
51+
<target>Խնդրում ենք մուտքագրել վավեր ամսաթիվ և ժամ։</target>
52+
</trans-unit>
53+
<trans-unit id="108">
54+
<source>Please enter a valid date.</source>
55+
<target>Խնդրում ենք մուտքագրել վավեր ամսաթիվ։</target>
56+
</trans-unit>
57+
<trans-unit id="109">
58+
<source>Please select a valid file.</source>
59+
<target>Խնդրում ենք ընտրել վավեր ֆայլ։</target>
60+
</trans-unit>
61+
<trans-unit id="110">
62+
<source>The hidden field is invalid.</source>
63+
<target>Թաքնված դաշտը անվավեր է։</target>
64+
</trans-unit>
65+
<trans-unit id="111">
66+
<source>Please enter an integer.</source>
67+
<target>Խնդրում ենք մուտքագրել ամբողջ թիվ։</target>
68+
</trans-unit>
69+
<trans-unit id="112">
70+
<source>Please select a valid language.</source>
71+
<target>Խնդրում ենք ընտրել վավեր լեզու։</target>
72+
</trans-unit>
73+
<trans-unit id="113">
74+
<source>Please select a valid locale.</source>
75+
<target>Խնդրում ենք ընտրել վավեր տեղայնացում։</target>
76+
</trans-unit>
77+
<trans-unit id="114">
78+
<source>Please enter a valid money amount.</source>
79+
<target>Խնդրում ենք մուտքագրել վավեր գումար։</target>
80+
</trans-unit>
81+
<trans-unit id="115">
82+
<source>Please enter a number.</source>
83+
<target>Խնդրում ենք մուտքագրել համար։</target>
84+
</trans-unit>
85+
<trans-unit 10000 id="116">
86+
<source>The password is invalid.</source>
87+
<target>Գաղտնաբառն անվավեր է։</target>
88+
</trans-unit>
89+
<trans-unit id="117">
90+
<source>Please enter a percentage value.</source>
91+
<target>Խնդրում ենք մուտքագրել տոկոսային արժեք։</target>
92+
</trans-unit>
93+
<trans-unit id="118">
94+
<source>The values do not match.</source>
95+
<target>Արժեքները չեն համընկնում։</target>
96+
</trans-unit>
97+
<trans-unit id="119">
98+
<source>Please enter a valid time.</source>
99+
<target>Մուտքագրեք վավեր ժամանակ։</target>
100+
</trans-unit>
101+
<trans-unit id="120">
102+
<source>Please select a valid timezone.</source>
103+
<target>Խնդրում ենք ընտրել վավեր ժամային գոտի։</target>
104+
</trans-unit>
105+
<trans-unit id="121">
106+
<source>Please enter a valid URL.</source>
107+
<target>Խնդրում ենք մուտքագրել վավեր URL։</target>
108+
</trans-unit>
109+
<trans-unit id="122">
110+
<source>Please enter a valid search term.</source>
111+
<target>Խնդրում ենք մուտքագրել վավեր որոնման տերմին։</target>
112+
</trans-unit>
113+
<trans-unit id="123">
114+
<source>Please provide a valid phone number.</source>
115+
<target>Խնդրում ենք տրամադրել վավեր հեռախոսահամար։</target>
116+
</trans-unit>
117+
<trans-unit id="124">
118+
<source>The checkbox has an invalid value.</source>
119+
<target>Նշման վանդակը անվավեր արժեք ունի։</target>
120+
</trans-unit>
121+
<trans-unit id="125">
122+
<source>Please enter a valid email address.</source>
123+
<target>Խնդրում ենք մուտքագրել վավեր էլ-հասցե։</target>
124+
</trans-unit>
125+
<trans-unit id="126">
126+
<source>Please select a valid option.</source>
127+
<target>Խնդրում ենք ընտրել ճիշտ տարբերակ։</target>
128+
</trans-unit>
129+
<trans-unit id="127">
130+
<source>Please select a valid range.</source>
131+
<target>Խնդրում ենք ընտրել վավեր տիրույթ։</target>
132+
</trans-unit>
133+
<trans-unit id="128">
134+
<source>Please enter a valid week.</source>
135+
<target>Մուտքագրեք վավեր շաբաթ։</target>
136+
</trans-unit>
17137
</body>
18138
</file>
19139
</xliff>

src/Symfony/Component/Form/Tests/Extension/Core/EventListener/ResizeFormListenerTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ public function testOnSubmitDeleteEmptyNotCompoundEntriesIfAllowDelete()
255255

256256
$data = [0 => 'first', 1 => ''];
257257
foreach ($data as $child => $dat) {
258-
$this->form->get($child)->setData($dat);
258+
$this->form->get($child)->submit($dat);
259259
}
260260
$event = new FormEvent($this->form, $data);
261261
$listener = new ResizeFormListener('text', [], false, true, true);
@@ -282,11 +282,11 @@ public function testOnSubmitDeleteEmptyCompoundEntriesIfAllowDelete()
282282

283283
$data = ['0' => ['name' => 'John'], '1' => ['name' => '']];
284284
foreach ($data as $child => $dat) {
285-
$this->form->get($child)->setData($dat);
285+
$this->form->get($child)->submit($dat);
286286
}
287287
$event = new FormEvent($this->form, $data);
288288
$callback = function ($data) {
289-
return '' === $data['name'];
289+
return null === $data['name'];
290290
};
291291
$listener = new ResizeFormListener('text', [], false, true, $callback);
292292
$listener->onSubmit($event);

src/Symfony/Component/Form/Tests/Extension/Core/Type/CollectionTypeTest.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\Form\Tests\Extension\Core\Type;
1313

1414
use Symfony\Component\Form\Exception\UnexpectedTypeException;
15+
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
1516
use Symfony\Component\Form\Form;
1617
use Symfony\Component\Form\Tests\Fixtures\Author;
1718
use Symfony\Component\Form\Tests\Fixtures\AuthorType;
@@ -212,6 +213,28 @@ public function testResizedDownIfSubmittedWithCompoundEmptyDataAndDeleteEmpty()
212213
$this->assertEquals([new Author('s_first', 's_last')], $form->getData());
213214
}
214215

216+
public function testNotDeleteEmptyIfInvalid()
217+
{
218+
$form = $this->factory->create(static::TESTED_TYPE, null, [
219+
'entry_type' => ChoiceType::class,
220+
'entry_options' => [
221+
'choices' => ['a', 'b'],
222+
],
223+
'allow_add' => true,
224+
'allow_delete' => true,
225+
'delete_empty' => true,
226+
]);
227+
228+
$form->submit(['a', 'x', '']);
229+
230+
$this->assertSame(['a'], $form->getData());
231+
$this->assertCount(2, $form);
232+
$this->assertTrue($form->has('1'));
233+
$this->assertFalse($form[1]->isValid());
234+
$this->assertNull($form[1]->getData());
235+
$this->assertSame('x', $form[1]->getViewData());
236+
}
237+
215238
public function testNotResizedIfSubmittedWithExtraData()
216239
{
217240
$form = $this->factory->create(static::TESTED_TYPE, null, [

0 commit comments

Comments
 (0)
0