-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Unique entity custom message #16345
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
Unique entity custom message #16345
Conversation
Looks like there is a problem here as many commits are not related to the changes made here. |
@fabpot Yes my PR was based on 2.6 but had some travis errors not related to my changes. Do i need to do a new PR ? (a clean PR) |
@Razmo You can rebase your changes on the current |
@xabbuh Thanks, it works 👍 |
Please do not merge but rebase instead. In fact, can you squash your commits in one please? |
Ok going to squash my commits in one (there is only one author, just done a mistake on my config for first commits) and i'll rebase on 2.8. |
@nicolas-grekas done |
@@ -135,13 +136,29 @@ public function validate($entity, Constraint $constraint) | |||
$errorPath = null !== $constraint->errorPath ? $constraint->errorPath : $fields[0]; | |||
$invalidValue = isset($criteria[$errorPath]) ? $criteria[$errorPath] : $criteria[$fields[0]]; | |||
|
|||
$vars = array(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's not necessary, is it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indeed, it is useless
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm going to remove it
👍 LGTM |
if (preg_match_all('/{{ ([a-zA-Z0-9_]+) }}/', $constraint->message, $vars) > 0) { | ||
|
||
if (!class_exists('Symfony\\Component\\PropertyAccess\\PropertyAccess')) { | ||
throw new \RuntimeException('Unable to access entity property as the Symfony PropertyAccess is not installed.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should probably explain why it is necessary
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PropertyAccess
component should be ship with standard edition right ? Why this check ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dupuchba You can use the Doctrine bridge without using the full framework.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, I am not sure if it's widespread but fair enough ! Thx @xabbuh
Any news on this one? |
Ping @stof |
@Razmo |
@jamyouss Do you need help to finish this one? |
@fabpot Yes please. Do you have another idea ? |
@jamyouss would you mind rebasing on branch 3.4 and changing the target branch on github also to 3.4? |
Closing as this PR is stale and it cannot be merged as is anyway. |
Add the possibility to have custom message for unique entity constraint.
For example if we have a collection of entities in a form, the message can be more expressive.
Example:
Reopen PR #15201 based now on branch 2.8