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

  • Home
  • SEARCH
  • 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 930519
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T20:20:54+00:00 2026-05-15T20:20:54+00:00

Newbie question. I’ve created a very simple LoginForm class in symfony. It checks if

  • 0

Newbie question.

I’ve created a very simple LoginForm class in symfony. It checks if the user inserts the username and the password in the field and It work as expected.

// UserLoginForm :: configure()

$this->setWidgets(array(
  'username' => new sfWidgetFormInputText(),
  'password' => new sfWidgetFormInputPassword(),
));
$this->setValidators(array(
  'username' => new sfValidatorString(array('required' => true),
  'password' => new sfValidatorString(array('required' => true)
));


// Action :: executeLogin()

$this->loginForm = new UserLoginForm();

if ($request->isMethod('post')) {
    $params = $request->getParameter('login');
    $this->loginForm->bind($request->getParameter('login'));

    if ($this->loginForm->isValid()) {
        // ... more code                
    }
}

Now I’m trying to check the presence of the username field in the db and if it does not exists, I want to invalidate the form. The same for the password: if the username + password pair doesn’t exist, but with a different message.

Trying to find the solution I searched in two possible ways:

In the action :

  • querying the db,
  • check the username,
  • invalidate the form username field (I want the error message in the resulting HTML),
  • same for the username + password check

In this case how I can invalidate the form ?
How to handle the error message in the template ?

In the form class calling the isValid() method :

  • add something to the setValidator()
  • OR add a post validator that call a private function which query the model

In this case how can I use the model in the Form class ?

Which is the best/fast approach ?
Other possibilities ?

  • 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-05-15T20:20:55+00:00Added an answer on May 15, 2026 at 8:20 pm

    I think it will be very useful to you to look at the code of the validator of sfDoctrineGuardPlugin. They create that post validator, and set it in the form. Even if you don’t want to use sfDoctrineGuardPlugin (or sfGuardPlugin if you use Propel) its code can be a valuable source of inspiration.

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

Sidebar

Related Questions

Newbie question... The objective: I intend to have an HTML text input field as
Newbie question: I just installed VisualSVN Server and created a repository. I noticed that
Newbie question... I am using silverlight to POST data to my GAE application class
Newbie question (I'm just getting started with Python and Pydev): I've created a project
Very newbie question. I want to overwrite the Main in my WPF app so
(IPhone newbie question) I've subclassed a UIViewController and a UIView , and created a
Newbie question here! I'm building a simple application that allows users to create and
Very newbie question. For instance, is this okay? <a href=allaboutpeanuts.html>Peanuts<img src=peanut.jpg> </a> I tried
Newbie question on drools. I am trying to access the following java class in
a newbie question here... I've created an entity data model (.edmx) file in one

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.