From 251ce8f92489cfb49f9a15c1c793b1befad01dd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Malte=20Schlu=CC=88ter?= Date: Thu, 18 Feb 2021 11:52:56 +0100 Subject: [PATCH 1/4] Add different header notations to tests --- .../Component/BrowserKit/Tests/HttpBrowserTest.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/Symfony/Component/BrowserKit/Tests/HttpBrowserTest.php b/src/Symfony/Component/BrowserKit/Tests/HttpBrowserTest.php index 4cd44aff70..8125d1a77c 100644 --- a/src/Symfony/Component/BrowserKit/Tests/HttpBrowserTest.php +++ b/src/Symfony/Component/BrowserKit/Tests/HttpBrowserTest.php @@ -63,6 +63,18 @@ class HttpBrowserTest extends AbstractBrowserTest ['POST', 'http://example.com/', [], [], ['CONTENT_TYPE' => 'application/json'], '["content"]'], ['POST', 'http://example.com/', ['headers' => $defaultHeaders + ['content-type' => 'application/json'], 'body' => '["content"]', 'max_redirects' => 0]], ]; + yield 'custom header with HTTP_ prefix' => [ + ['PUT', 'http://example.com/', [], [], ['HTTP_CONTENT_TYPE' => 'application/json'], '["content"]'], + ['PUT', 'http://example.com/', ['headers' => $defaultHeaders + ['content-type' => 'application/json'], 'body' => '["content"]', 'max_redirects' => 0]], + ]; + yield 'modify notation of custom header with HTTP_ prefix' => [ + ['PUT', 'http://example.com/', [], [], ['HTTP_Content-Type' => 'application/json'], '["content"]'], + ['PUT', 'http://example.com/', ['headers' => $defaultHeaders + ['content-type' => 'application/json'], 'body' => '["content"]', 'max_redirects' => 0]], + ]; + yield 'modify notation of custom header' => [ + ['PUT', 'http://example.com/', [], [], ['Content-Type' => 'application/json'], '["content"]'], + ['PUT', 'http://example.com/', ['headers' => $defaultHeaders + ['content-type' => 'application/json'], 'body' => '["content"]', 'max_redirects' => 0]], + ]; } public function testMultiPartRequestWithSingleFile() From 1329689acec3f8cfbcf1f75902ba4617c38e2831 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Fri, 19 Feb 2021 10:48:50 +0100 Subject: [PATCH 2/4] cs fix --- .../Compiler/ResolveInstanceofConditionalsPass.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/DependencyInjection/Compiler/ResolveInstanceofConditionalsPass.php b/src/Symfony/Component/DependencyInjection/Compiler/ResolveInstanceofConditionalsPass.php index 92b48ed888..37ad34954d 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/ResolveInstanceofConditionalsPass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/ResolveInstanceofConditionalsPass.php @@ -76,7 +76,7 @@ class ResolveInstanceofConditionalsPass implements CompilerPassInterface $reflectionClass = null; foreach ($conditionals as $interface => $instanceofDefs) { - if ($interface !== $class && !(null === $reflectionClass ? $reflectionClass = ($container->getReflectionClass($class, false) ?: false) : $reflectionClass)) { + if ($interface !== $class && !($reflectionClass ?? $reflectionClass = $container->getReflectionClass($class, false) ?: false)) { continue; } From d1c3e21effe4c8329bc904a51e6a689b4da12e9e Mon Sep 17 00:00:00 2001 From: Erik Saunier Date: Wed, 17 Feb 2021 14:06:36 +0100 Subject: [PATCH 3/4] Add Symfony Armenian Translations --- .../Resources/translations/validators.hy.xlf | 120 ++++++++++++++++++ 1 file changed, 120 insertions(+) diff --git a/src/Symfony/Component/Form/Resources/translations/validators.hy.xlf b/src/Symfony/Component/Form/Resources/translations/validators.hy.xlf index bdba3fe814..10ac326fb1 100644 --- a/src/Symfony/Component/Form/Resources/translations/validators.hy.xlf +++ b/src/Symfony/Component/Form/Resources/translations/validators.hy.xlf @@ -14,6 +14,126 @@ The CSRF token is invalid. Please try to resubmit the form. CSRF արժեքը անթույլատրելի է. Փորձեք նորից ուղարկել ձևը։ + + This value is not a valid HTML5 color. + Այս արժեքը վավեր HTML5 գույն չէ։ + + + Please enter a valid birthdate. + Խնդրում ենք մուտքագրել վավեր ծննդյան ամսաթիվ։ + + + The selected choice is invalid. + Ընտրված ընտրությունն անվավեր է։ + + + The collection is invalid. + Համախումբն անվավեր է։ + + + Please select a valid color. + Խնդրում ենք ընտրել վավեր գույն։ + + + Please select a valid country. + Խնդրում ենք ընտրել վավեր երկիր։ + + + Please select a valid currency. + Խնդրում ենք ընտրել վավեր արժույթ։ + + + Please choose a valid date interval. + Խնդրում ենք ընտրել ճիշտ ամսաթվերի միջակայք։ + + + Please enter a valid date and time. + Խնդրում ենք մուտքագրել վավեր ամսաթիվ և ժամ։ + + + Please enter a valid date. + Խնդրում ենք մուտքագրել վավեր ամսաթիվ։ + + + Please select a valid file. + Խնդրում ենք ընտրել վավեր ֆայլ։ + + + The hidden field is invalid. + Թաքնված դաշտը անվավեր է։ + + + Please enter an integer. + Խնդրում ենք մուտքագրել ամբողջ թիվ։ + + + Please select a valid language. + Խնդրում ենք ընտրել վավեր լեզու։ + + + Please select a valid locale. + Խնդրում ենք ընտրել վավեր տեղայնացում։ + + + Please enter a valid money amount. + Խնդրում ենք մուտքագրել վավեր գումար։ + + + Please enter a number. + Խնդրում ենք մուտքագրել համար։ + + + The password is invalid. + Գաղտնաբառն անվավեր է։ + + + Please enter a percentage value. + Խնդրում ենք մուտքագրել տոկոսային արժեք։ + + + The values do not match. + Արժեքները չեն համընկնում։ + + + Please enter a valid time. + Մուտքագրեք վավեր ժամանակ։ + + + Please select a valid timezone. + Խնդրում ենք ընտրել վավեր ժամային գոտի։ + + + Please enter a valid URL. + Խնդրում ենք մուտքագրել վավեր URL։ + + + Please enter a valid search term. + Խնդրում ենք մուտքագրել վավեր որոնման տերմին։ + + + Please provide a valid phone number. + Խնդրում ենք տրամադրել վավեր հեռախոսահամար։ + + + The checkbox has an invalid value. + Նշման վանդակը անվավեր արժեք ունի։ + + + Please enter a valid email address. + Խնդրում ենք մուտքագրել վավեր էլ-հասցե։ + + + Please select a valid option. + Խնդրում ենք ընտրել ճիշտ տարբերակ։ + + + Please select a valid range. + Խնդրում ենք ընտրել վավեր տիրույթ։ + + + Please enter a valid week. + Մուտքագրեք վավեր շաբաթ։ + From e4911554e38968b2cc30ba2c87414b077869e08e Mon Sep 17 00:00:00 2001 From: Yonel Ceruto Date: Fri, 19 Feb 2021 17:17:21 -0500 Subject: [PATCH 4/4] [Form] Ignoring invalid forms from delete_empty behavior in CollectionType --- .../Core/EventListener/ResizeFormListener.php | 4 ++++ .../EventListener/ResizeFormListenerTest.php | 6 ++--- .../Core/Type/CollectionTypeTest.php | 23 +++++++++++++++++++ 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/Form/Extension/Core/EventListener/ResizeFormListener.php b/src/Symfony/Component/Form/Extension/Core/EventListener/ResizeFormListener.php index d978117552..813456b95e 100644 --- a/src/Symfony/Component/Form/Extension/Core/EventListener/ResizeFormListener.php +++ b/src/Symfony/Component/Form/Extension/Core/EventListener/ResizeFormListener.php @@ -132,6 +132,10 @@ class ResizeFormListener implements EventSubscriberInterface $previousData = $form->getData(); /** @var FormInterface $child */ foreach ($form as $name => $child) { + if (!$child->isValid() || !$child->isSynchronized()) { + continue; + } + $isNew = !isset($previousData[$name]); $isEmpty = \is_callable($this->deleteEmpty) ? ($this->deleteEmpty)($child->getData()) : $child->isEmpty(); diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/ResizeFormListenerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/ResizeFormListenerTest.php index 5e0fc84f02..ac59919e7f 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/ResizeFormListenerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/ResizeFormListenerTest.php @@ -255,7 +255,7 @@ class ResizeFormListenerTest extends TestCase $data = [0 => 'first', 1 => '']; foreach ($data as $child => $dat) { - $this->form->get($child)->setData($dat); + $this->form->get($child)->submit($dat); } $event = new FormEvent($this->form, $data); $listener = new ResizeFormListener('text', [], false, true, true); @@ -282,11 +282,11 @@ class ResizeFormListenerTest extends TestCase $data = ['0' => ['name' => 'John'], '1' => ['name' => '']]; foreach ($data as $child => $dat) { - $this->form->get($child)->setData($dat); + $this->form->get($child)->submit($dat); } $event = new FormEvent($this->form, $data); $callback = function ($data) { - return '' === $data['name']; + return null === $data['name']; }; $listener = new ResizeFormListener('text', [], false, true, $callback); $listener->onSubmit($event); diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/CollectionTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/CollectionTypeTest.php index e98a0c1744..b66ca07488 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/CollectionTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/CollectionTypeTest.php @@ -12,6 +12,7 @@ namespace Symfony\Component\Form\Tests\Extension\Core\Type; use Symfony\Component\Form\Exception\UnexpectedTypeException; +use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\Form; use Symfony\Component\Form\Tests\Fixtures\Author; use Symfony\Component\Form\Tests\Fixtures\AuthorType; @@ -211,6 +212,28 @@ class CollectionTypeTest extends BaseTypeTest $this->assertEquals([new Author('s_first', 's_last')], $form->getData()); } + public function testNotDeleteEmptyIfInvalid() + { + $form = $this->factory->create(static::TESTED_TYPE, null, [ + 'entry_type' => ChoiceType::class, + 'entry_options' => [ + 'choices' => ['a', 'b'], + ], + 'allow_add' => true, + 'allow_delete' => true, + 'delete_empty' => true, + ]); + + $form->submit(['a', 'x', '']); + + $this->assertSame(['a'], $form->getData()); + $this->assertCount(2, $form); + $this->assertTrue($form->has('1')); + $this->assertFalse($form[1]->isValid()); + $this->assertNull($form[1]->getData()); + $this->assertSame('x', $form[1]->getViewData()); + } + public function testNotResizedIfSubmittedWithExtraData() { $form = $this->factory->create(static::TESTED_TYPE, null, [