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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T06:13:05+00:00 2026-06-09T06:13:05+00:00

I am writing a more advanced file form element, more of a widget that

  • 0

I am writing a more advanced file form element, more of a widget that displays the currently loaded uploaded image as well as validating image sizes etc.

If the file validates, I want the form element itself to copy the file to a publicly accessible folder. This will mean that a) the image can be displayed and b) if the whole form doesn’t validate, the user does not need to re-upload the image.

Anyway that’s the back story, but essentially I need to figure out how to get a function from within a form element to run when the form validates that element. Something like creating an onValidate() function in the form element class.

Most importantly I need a solution that doesn’t spill out into the controller (or as little as possible). I am struggling to find a clean way to implement this.

I would like to do something like this…

class File extends Element implements InputProviderInterface
{

....

public function isValid()
{
    if ( $isValid = parent::isValid() ) {
        echo "Hi there, glad you called";
    }

    return $isValid;
}
  • 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-09T06:13:08+00:00Added an answer on June 9, 2026 at 6:13 am

    The Zend\Form\Element::getValidator() function will be called on each validation run.

    I think you should call a class which’s concern it is to copy the file.
    Maybe you want to raise an event to make it more decoupled.

    Validation and Filtering are now part of the InputFilter class.
    Your goal is to write an dedicated Validator and hardwire it with your Element.

    An example of how to achieve this, look at Zend\Form\Element\Select which as a hardwired InArrayValidator in its onValidate() method.

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

Sidebar

Related Questions

we currently experience some file writing/encoding problems that we cannot reproduce. Actually there are
I'm writing an application for windows 8 that displays images from a json file.
I'm currently porting some batch files to node.js. I feel more comfortable writing in
I'm writing a windows service that import an XML file into a SQLite database.
Looking for help on writing a Perl program that takes an input file and
i am writing a c++ function that will parse .xml file. i Used system(grep);
I am writing a simple shell program that must take input from a file
I'm writing a Windows Form app that uses an API (the smartFOCUS API, to
I am writing a powershell advanced function that will take input from the pipeline.
Code is read more often then updated. Writing more readable code is better than

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.