I'm currently fighting with ExpressionLanguage validation regarding to a constraint wanted on form validation :
My form :
- Text item
- Entity1 item selector (dropdown)
- Entity2 item selector (dropdown)
- Textarea item
My wishes :
- One error trigger on condition Text Item is empty and Entity1 selector is empty
- Another error trigger on condition :
Entity1.id == XXandEntity2.id == YYand Textarea is empty
So far, I got this in validation.yml :
Experveo\ShopBundle\Entity\Vehicle:
constraints:
- Expression:
expression: "this.getTextItem() != '' | this.getEntity1() != ''"
message: error1.
It seems I need to put the opposite condition to make it work. So far I didn't find any advanced clue on documentation, nor in expression language syntax help.
How can I achieve those conditions? Following is not working at all...
- Expression:
expression: >
this.getTextItem() == ''
&& this.getEntity1() != ''
&& this.getEntity1().getId() === 49
&& this.getEntity2() != ''
&& this.getEntity2() === 914
&& this.getTextAreaItem() == ''"
message: error2.
== ''for your two entities, not the other way around.