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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:22:39+00:00 2026-05-22T18:22:39+00:00

hi i am using a zend image element in my project , i have

  • 0

hi i am using a zend image element in my project , i have validated the field . if i choose other than an image and submit the form , a default error message is displayed , i tried to remove it and add a custom message by

    $image->removeDecorator('Error');
    $image->addErrorMessage('Invalid image');

but it is not working . the error message is

File ‘.zfproject.xml’ is no image,
‘application/xml’ detected

how can i add a custom error message and remove the default error meassage , please help ….

this is my code

    $image = new Zend_Form_Element_File('image');
    $image->setLabel('Image URL :');
    $image->setDestination($imagePath);
    $image->addValidator('IsImage', false);
    //$image->removeDecorator('Error');
    //$image->addErrorMessage('tester');
  • 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-22T18:22:40+00:00Added an answer on May 22, 2026 at 6:22 pm

    The validator message is stored in Zend/Validate/File/IsImage.php here:

        protected $_messageTemplates = array(
        self::FALSE_TYPE   => "File '%value%' is no image, '%type%' detected",
        self::NOT_DETECTED => "The mimetype of file '%value%' could not be detected",
        self::NOT_READABLE => "File '%value%' is not readable or does not exist",
    );
    

    The easiest way around this would be subclass the validator:

    class Custom_Validate_File_IsImage extends Zend_Validate_File_IsImage
    {
        /**
         * @var array Error message templates
         */
        protected $_messageTemplates = array(
            self::FALSE_TYPE   => "Customize your message to whatever you want to right here.",
            self::NOT_DETECTED => "The mimetype of file '%value%' could not be detected",
            self::NOT_READABLE => "File '%value%' is not readable or does not exist",
        );
    }
    

    and use the custom validator instead with :

    $image->addValidator(new Custom_Validate_File_IsImage());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

hi i am using zend form , i created a Zend_Form_Element_Radio element that have
I am using jquery validation plugin and zend framework. I have my form in
I'm using Doctrine 1.2 as my ORM for a Zend Framework Project. I have
Using Zend_Form, how would I create form elements like this: <input type=text name=element[1] value=
Using Zend_Form, how would I create form elements like this <input type=text name=element[1] value=/>
Im using Zend form. What should I do to get correct action parameter in
I'm working on a form upload element that can be used in the Zend
I am using Zend Framework, and am creating a image upload for users. So,
I am making a PHP image uploader using the Zend Framework which will upload
I am using Zend Framework 1.11 and after editing a record, the image file

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.