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() diff --git a/src/Symfony/Component/DependencyInjection/Compiler/ResolveInstanceofConditionalsPass.php b/src/Symfony/Component/DependencyInjection/Compiler/ResolveInstanceofConditionalsPass.php index 4aa33aad1a..b211b84e13 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/ResolveInstanceofConditionalsPass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/ResolveInstanceofConditionalsPass.php @@ -73,7 +73,7 @@ class ResolveInstanceofConditionalsPass implements CompilerPassInterface $parent = $definition instanceof ChildDefinition ? $definition->getParent() : 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; } 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/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. + Մուտքագրեք վավեր շաբաթ։ + 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 1940517a3f..9bcb22efe0 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 b3b05c98eb..b7e68ba0d0 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; @@ -212,6 +213,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, [