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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T17:43:37+00:00 2026-05-28T17:43:37+00:00

In my project we have a Form where the user either needs to upload

  • 0

In my project we have a Form where the user either needs to upload a file or specify some other information, for example in a text input.

I know that there is the possibility to attach a Count validator to the Form Element, and this works like this:

$upload->addValidator('Count', false, array('min' => 1, 'max' => 3));

This validator gets called, no matter if there are files uploaded or not. But as soon as i replace the validator with a custom version, and do not upload any files, the validator does not get called.

Looking at the isValid() method of Zend_File_Transfer_Adapter_Abstract, I can see the problem:

[...]
    foreach($check as $key => $content) {
        if (array_key_exists('validators', $content) &&
            in_array('Zend_Validate_File_Count', $content['validators'])) {
            $validator = $this->_validators['Zend_Validate_File_Count'];
            $count     = $content;
[...]

Seems like the Count Validator got some special treatment here. But how can I include my customized Validator, without overwriting Zend Files?

Because we do not extend the Zend_Form class, sadly I also cannot overwrite the isValid() method of the involved Form. Any Ideas left? Thanks for your time!

  • 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-28T17:43:38+00:00Added an answer on May 28, 2026 at 5:43 pm

    This would probably be easiest with a bit of ajax. That way you could evaluate the selection prior to posting the form.
    To do it in PHP, an Element validator is probably not the way to go. It would be better to handle the selection with an if() statment.

    pseudocode...
    //if file element contains something and text doesn't
    if($this->getRequest->getPost('file'=='' && 'text' != ''){
        $file = $form->file->receive();
    
        //do some stuff
    //if text element contains something and file dosen't
    }elseif ($this->getRequst->getPost('file' != '' && 'text' == '') {
        if($form->isValid($this->_request->getPost('text')) {
          //do some stuff
        }
    }
    

    This is the idea, hope it helps.

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

Sidebar

Related Questions

In my windows forms project I have a parent form that is creates other
On a flex project, I have a slider and text box on a form
I have form that displays information on a project. Most of the fields on
in my project i have one registration form which is developed in C#.net.to this
I'm developing a small POS for a university project. I have a form which
I have a project to setup an anonymous feedback form to our website. I
I have a project with a main MDI form. There is a child MDI
OK, another road bump in my current project. I have never had form elements
I have a c# windows form project using watin. I would love to attach
I have a WinForm project that contains a form called MainUI. You can see

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.