hi, everyone I set validation.yml to an entity like below:
Acme\DefaultBundle\Entity\Blog: properties: title: - NotBlank: {message: Title field is required.} so when I create a form, it automatically validate the form input, it always stop posting if title field is empty, as i set tht entity constraint. it's very good when I create a new blog and edit a new blog, but what if I create a search form, the title field is not required to input, and I want to leave the title field empty, when the form post, it will search all blogs as there is no keyword attach to the SQL SELECT statement. I search google for long time, as not related answer, I still struggled about this problem, public function searchAction() { $em = $this->get('doctrine')->getEntityManager(); $request = $this->get('request'); // search form // ======================================== $blog = new Blog(); $blogType = new BlogType($em); $form = $this->get('form.factory')->create($blogType, $blog); // ========================================= // If the request method is POST then process the form submitted. if ($request->getMethod() == 'POST') { $form->bindRequest($request); } return $this->render('AcmeDefaultBundle:Blog:search.html.twig', array( 'form' => $form->createView(), 'blog' => $blog )); } DO I need to create a new entity which there is no constraint to the title property? OR take out the constraint to the validation.yml and is it possible to set constraint dynamically to title field after form post? Any help would be very appreciated. -- If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com You received this message because you are subscribed to the Google Groups "symfony users" group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en