-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Form] Expression validation constraint on form without a Data Class #22403
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
Comments
Yes, it's the normal behavior, without However, in this case, you can to add the For example: $form = $this
->createFormBuilder(null, [
'constraints' => [
new Expression([
'expression' => 'value["firstName"] == "john"',
])
]
])
->add('firstName')
->add('lastName')
->getForm(); |
This is what I am doing but I hoped there was another solution. Maybe something like a |
Maybe we talking about to pass a new variable to the expression context like the current $form = $this
->createFormBuilder()
->add('firstName', null, [
'constraints' => [
new Expression([
'expression' => 'root["firstName"].getData() != root["lastName"].getData()',
])
]
])
->add('lastName')
->getForm(); |
It doesn't seem that there is much concern about adding something like the root form to the context of the ExpressionLanguage being used when validating a form. Thus, I am going to close here. |
Hello,
When using form without a data class (see: http://symfony.com/doc/current/form/without_class.html), we are not able to use expression to access other fields data.
Only the
value
var seems to be filled.If I try something like
this.firstName
, I am not able to access others fields values.Is it normal?
The text was updated successfully, but these errors were encountered: