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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T17:57:12+00:00 2026-06-05T17:57:12+00:00

I create my forms via extending Zend_Form. And I use one Form for addAction()

  • 0

I create my forms via extending Zend_Form. And I use one Form for addAction() and editAction(). When I want to remove Elements within the editing process I can do so easily via $form->removeElement('x').

But what would be the best approach on removing a field from the validator?

1) Removing and Adding the newly set validator

//Controllers editAction()
$form->removeValidator('Db_NoRecordExists');
$form->addValidator('Db_NoRecordExists', true, array(
  'table'=>'table', 
  'field'=>'field',
  'exclude'=>array(
    'field'=>'id',
    'value'=>$this->_getParam('id')
  )
));

2) Injecting editing ID into the Form

//Forms Contstructor
public function __construct($idToEdit=0, $options=null)
{
   $this->setIdToEdit($idToEdit);
   parent::__construct($options);
}

//within init()
$formField->addValidator('Db_NoRecordExists', true, array(
  'table'=>'table', 
  'field'=>'field',
  'exclude'=>array(
    'field'=>'id',
    'value'=>$this->getIdToEdit()
  )
));

//Controller calling the form like this:
$form = new Custom_Form($this->_getParam('id'), $options);

3) Something else?
Maybe there is even something else I am missing, to me though somehow both ideas don’t look too well to me.

  • 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-05T17:57:13+00:00Added an answer on June 5, 2026 at 5:57 pm

    For a cleaner use of SO here the answer as a post

    //SOLUTION Okay, so while browsing to Zends Sourcecode (should have done that before asking…) i found the best solution (i guess). The Abstract DB Validation classes got a
    function setExclude() so we can then use it in a nice flow:

    //Inside Controller before valling $form->isValid()
    $form->getElement('x')->getValidator('Db_NoRecordExists')->setExclude(array(
      'field'=>'some_id',
      'value'=>$idToEdit
    ))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I think its easy to create form via only html and do not use
I'm trying to create a form that clients would complete via the web, so
Is there any tools using which I can use to create Windows forms from
I want to create a view that contains two forms with their submit buttons.
i have the following schema and i want to create a Form with Symfony
I can create forms via templates with no problem. I found a plugin (create-page)
I'm trying to create a strategy for handling popup forms for use throughout any
I want to create a GUI in Oracle form 10g, the purpose of creating
I am trying to create an object via an API, i.e. no forms are
I am building a library to automatically create forms for Objects in the project

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.