Forms 表单类型,如何获取注释错误
您知道我如何从实体中获取注释错误以在我的小树枝页面中显示它们吗 我的控制器:Forms 表单类型,如何获取注释错误,forms,symfony,annotations,abstract-type,Forms,Symfony,Annotations,Abstract Type,您知道我如何从实体中获取注释错误以在我的小树枝页面中显示它们吗 我的控制器: class HomeController extends Controller { public function indexAction(Request $request) { $Sms = new Sms(); $form = $this->createForm(new SmsType(), $Sms); if ($request->isMethod
class HomeController extends Controller
{
public function indexAction(Request $request)
{
$Sms = new Sms();
$form = $this->createForm(new SmsType(), $Sms);
if ($request->isMethod('POST')) {
$form->bind($request);
if($form->isValid())
{
$request->getSession()->getFlashBag()->add('success', true);
return $this->redirect($this->generateUrl('dimi_esg_contact_success'));
}
}
return $this->render('DimiEsgBundle:Home:index.html.twig', array('form' => $form->createView()));
}
}
我的实体类:
class Sms
{
/**
* @var integer $mobile
*
* @Assert\NotBlank(
* message="Ne peut être vide."
* )
* @Assert\Regex(
* pattern="/^(06|07)[0-9]{8}$/",
* match=false,
* message="Doit être un mobile français."
* )
*/
private $mobile;
//...
}
谢谢大家的帮助。
向你问好,迪米特里
编辑
要显示错误,我们必须在细枝模板中使用form_error()。您好,Dimi,请发布您的细枝页面,我猜您缺少form_error()。hoooooo!!谢谢你!我错过了表单_error()。。。谢谢你!请你加上这个作为回答并接受它好吗?