Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8748303
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:30:08+00:00 2026-06-13T12:30:08+00:00

I modify my code to follow @Stony advices. I would like to customise my

  • 0

I modify my code to follow @Stony advices.

I would like to customise my email input error. I try to follow the symfony2 tutorial but it doesn’t work.

I follow symfony validation tutorial and I create my yml file, but when I fill my email fiel with bad adress, the error display is still the symfony default error and not my custom message…

/**
 *
 * @Route("/info")
 */
class InfoController extends BaseController
{
    public function contactusAction(Request $request)
    {   
    $constraint = new Collection(array('email' => new Email(array('message' => 'Adresse email invalide')),));

    $contact = new ContactUs(); 
    $form = $this->createFormBuilder($contact)
        ->add('nom', 'text')
        ->add('mail', 'email')
        ->add('sujet', 'choice', array('choices' => array('pt' => 'Problemes techniques', 'bi' => 'Boite a idees', 'd' => 'Divers')))
        ->add('msg', 'textarea')
        ->getForm();
    }
}

Here is my view

<form action="" method="post" {{ form_enctype(form) }} class="contactus">
        {{ form_errors(form) }}
        <div>
            {{ form_label(form.nom, 'Nom : ') }}
            {{ form_errors(form.nom) }}
            {{ form_widget(form.nom) }}
            </div>
            <div>
            {{ form_label(form.mail, 'Email : ') }}
            {{ form_errors(form.mail) }}
            {{ form_widget(form.mail) }}
            </div>
        <div>
            {{ form_label(form.sujet, 'Sujet : ') }}
            {{ form_errors(form.sujet) }}
            {{ form_widget(form.sujet) }}
            </div>
        <div>
            {{ form_label(form.msg, 'Message : ') }}
            {{ form_errors(form.msg) }}
            {{ form_widget(form.msg) }}
            </div>
        <input type="submit" value="Envoyer" />
        {{ form_rest(form) }}
    </form>

Here is my yml file

PROJECT\CoreBundle\Entity\ContactUs:
    properties:
        mail:
            - Email:
                message: Adresse email invalide.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T12:30:09+00:00Added an answer on June 13, 2026 at 12:30 pm

    I think the error message is very clear:

    $form = $this->createFormBuilder($contact, array('constraints' => $constraint))
    

    there is no second option constraint. I don’t know what your goal is but this is not the correct way.

    If you want some validation you should look at Creating Form Classes in your Tutorial. There you can see how you can define Form and Type classes and how to set validation on the fields.

    Some more information: Validation

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How would I modify this code to show the animated movement (item moving from
I am trying to modify the code below to check the input from a
is it possible to modify the follow standard code for posting a facebook feed
I have built my own browser 9see attached code) however I would like to
I want to modify some code in the Eclipse JDT itself (In the Debug
I have to modify some code in a application I am working on that
I'm trying to modify the code from this script . Basically I'm trying to
Is there anyway I can modify this code example #include <stdlib.h> #include <iostream> class
I'm hoping someone can modify my code below to show me exactly how to
With Clojure (and other Lisp dialects) you can modify running code. So, when a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.