필드 수준에서 @Assert \ Expression (http://symfony.com/doc/2.4/reference/constraints/Expression.html)으로 속성의 유효성을 검사하려고합니다.Assert Expression 유효성 검사가 symfony 2.4의 속성 레벨에서 작동하지 않습니다.
그것은이 코드는 클래스 수준에서 작동:
/**
* Foo
*
* @ORM\Table(name="foo")
* @ORM\HasLifecycleCallbacks()
* @UniqueEntity("slug")
* @Assert\Expression(
* "this.getPriceFor2PaxStandard() != null or (this.getPriceFor2PaxStandard() == null and !this.isPriceForAccLevelRequired('standard'))",
* message="The price for 2 pax standard is required",
* groups={"agency_tripEdit_finalsave"}
*)
*
*/
class Foo implements ISpellcheckerLocaleProvider, ProcessStatusAware, DataTransformer
{
하지만 속성 레벨에서 동일한 코드를 (잘되어야하는) 사용하는 경우 작동하지 않습니다 : 또한
/**
* @var decimal
*
* @ORM\Column(name="price_for_2_pax_standard", type="decimal", precision=16, scale=4, nullable=true)
* @Assert\Expression(
* "this.getPriceFor2PaxStandard() != null or (this.getPriceFor2PaxStandard() == null and !this.isPriceForAccLevelRequired('standard'))",
* message="The price for 2 pax standard is required",
* groups={"agency_tripEdit_finalsave"}
*)
*/
private $priceFor2PaxStandard;
는 속성 레벨로 asseriont를 사용할 때 this.getPriceFor2PaxStandard()
대신 value
을 사용하는 경우에도 작동하지 않습니다.
힌트 :-)
아이디어가 있으십니까? :/ –