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 6775607
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:55:35+00:00 2026-05-26T15:55:35+00:00

I have one issue when I am trying to use setValidator() (not setValidators )

  • 0

I have one issue when I am trying to use setValidator() (not setValidators) in action class file.

this is my base form class code..

public function setup()
  {
    $this->setWidgets(array(
      'id'         => new sfWidgetFormInputHidden(),
      'name'       => new sfWidgetFormInputText(),
      'age'        => new sfWidgetFormChoice(array('choices' => array('21' => '21', '22' => '22', '23' => '23', '24' => '24', '25' => '25', '26' => '26', '27' => '27', '28' => '28', '29' => '29', '30' => '30'))),
      'gender'     => new sfWidgetFormChoice(array('choices' => array('Male' => 'Male', 'Female' => 'Female'))),
      'email'      => new sfWidgetFormInputText(),
      'salt'       => new sfWidgetFormInputText(),
      'password'   => new sfWidgetFormInputPassword(array('type' => 'password')),
      'created_at' => new sfWidgetFormDateTime(),
      'updated_at' => new sfWidgetFormDateTime(),
    ));

    $this->setValidators(array(      
      'id'         => new sfValidatorPass(),    
      'name'       => new sfValidatorString(array('required' => true)),
      'age'        => new sfValidatorPass(),      
      'gender'     => new sfValidatorChoice(array('choices' => array('Male','Female'))),
      'email'      => new sfValidatorEmail(array('required' => true)),
      'password'   => new sfValidatorString(array('required' => true)),
      'created_at' => new sfValidatorDateTime(),
      'updated_at' => new sfValidatorDateTime(),
    ));

    $this->widgetSchema->setNameFormat('signin[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);


    //$this->validatorSchema->setPostValidator(new sfUserValidate());

    $this->setupInheritance();

    parent::setup();
  }

this is my action class code..

public function executeNewuser($request)
  {
      $this->form = new UsersForm();
      $this->form->getWidgetSchema()->setNameFormat('users[%s]');

      //$this->form->setValidators(array('name' => new sfValidatorDoctrineUnique(array('model'  => 'Users','column' => 'name'))));

      $this->form->setValidator(array('name' => new sfValidatorDoctrineUnique(array('model'  => 'Users','column' => 'name'))));



      if($request->isMethod('post'))
      {
        $this->form->bind($request->getParameter('users'));
        if($this->form->isValid())
        {      
            echo "Hello";exit;
        }  

      }
  }

i am getting following error

Catchable fatal error: Argument 2 passed to sfForm::setValidator() must be an instance of sfValidatorBase, none given, called in /home/hardik/web/demo/apps/frontend/modules/user/actions/actions.class.php on line 77

i just need to override validator for name field in action class.

  • 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-26T15:55:36+00:00Added an answer on May 26, 2026 at 3:55 pm

    Your syntax is wrong. Look at setValidator‘s signature.
    You should be doing this:

    $this->form->setValidator(
      'name', 
      new sfValidatorDoctrineUnique(array('model'  => 'Users','column' => 'name')));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

my issue lokks similar to this one: (link) but i have one-to-many association: <set
I am new to MVC and facing one issue. I have a xml file
I have one issue related to JTree swing component, I want to use JTree
I am trying to use BlockUI in a table to have one row blocked
I have one issue with Datetime Picker In my firstview i have button.If i
I have one issue with UInavigationcontroller In my firstview i have button.If i click
OK, I am sorting an XMLListCollection in alphabetical order. I have one issue though.
I have one main outstanding issue, I know now how to databind to lists
I have got one weird issue. I am working on an asp .net mvc
We're using SQL Server 2000 Query Analyser, and one issue we have is that

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.