Optional embed form in Symfony 2

前端 未结 5 1931
予麋鹿
予麋鹿 2021-01-16 11:00

I have two entities in my system: Person and Phone as the following code.

class Person
{
    /**
     * @ORM\\Id
     * @ORM\\Colum         


        
5条回答
  •  一生所求
    2021-01-16 11:38

    For those passing by, with newer versions of Symfony you can do :

    /**
     *
     * @Assert\Callback()
     */
    public function validatePhone(ExecutionContextInterface $context)
    {
        if (/* Fields are not empty */)
        {
            $context->validate($this->getPhone(), 'phone', array("phone_validation"));
        }
    }
    

提交回复
热议问题