Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Form] invalidate forms on transformation failures #28731

Merged
merged 1 commit into from Nov 12, 2018

Conversation

xabbuh
Copy link
Member

@xabbuh xabbuh commented Oct 4, 2018

Q A
Branch? 2.8
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #20916, #21242, #28584
License MIT
Doc PR

@xabbuh xabbuh added this to the 2.8 milestone Oct 4, 2018
@xabbuh xabbuh force-pushed the issue-20916 branch 4 times, most recently from b7df8b9 to 6cf76d1 Compare October 31, 2018 07:07
@xabbuh xabbuh changed the title [WIP][Form] invalidate forms on transformation failures [Form] invalidate forms on transformation failures Oct 31, 2018
@xabbuh
Copy link
Member Author

xabbuh commented Oct 31, 2018

Test added, PR is ready from my POV

$message = 'This value is not valid.';

if (null !== $this->translator) {
$message = $this->translator->trans($message, array('{{ value }}' => $clientDataAsString));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The message is static then shouldn't the placeholder be there? ->trans('This value {{ value }} is not valid.', array('{{ value }}' => $clientDataAsString)) ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed, thanks for catching it

$message = $this->translator->trans($message, array('{{ value }}' => $clientDataAsString));
}

$form->addError(new FormError($message, 'This value is not valid.', array('{{ value }}' => $clientDataAsString), null, $form->getTransformationFailure()));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here for the message template (2nd argument)

@xabbuh
Copy link
Member Author

xabbuh commented Nov 10, 2018

ping @symfony/deciders :)

foreach ($form as $child) {
if (!$child->isSynchronized()) {
$childrenSynchronized = false;
break;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be more elegant to just return here. Then you wouldn't need $childrenSynchronized variable and guard it later at all

Copy link
Contributor

@HeahDude HeahDude left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So elegant :), 👍

@fabpot
Copy link
Member

fabpot commented Nov 12, 2018

Thank you @xabbuh.

@fabpot fabpot merged commit 385d9df into symfony:2.8 Nov 12, 2018
fabpot added a commit that referenced this pull request Nov 12, 2018
This PR was merged into the 2.8 branch.

Discussion
----------

[Form] invalidate forms on transformation failures

| Q             | A
| ------------- | ---
| Branch?       | 2.8
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #20916, #21242, #28584
| License       | MIT
| Doc PR        |

Commits
-------

385d9df invalidate forms on transformation failures
@xabbuh xabbuh deleted the issue-20916 branch November 12, 2018 07:18
@fabpot fabpot mentioned this pull request Nov 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants