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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T15:04:05+00:00 2026-05-10T15:04:05+00:00

When using a Zend_Form , the only way to validate that an input is

  • 0

When using a Zend_Form, the only way to validate that an input is not left blank is to do

$element->setRequired(true); 

If this is not set and the element is blank, it appears to me that validation is not run on the element.

If I do use setRequired(), the element is automatically given the standard NotEmpty validator. The thing is that the error message with this validator sucks, ‘Value is empty, but a non-empty value is required’. I want to change this message. At the moment I have done this by changing the Zend_Validate_NotEmpty class, but this is a bit hacky.

I would ideally like to be able to use my own class (derived from Zend_Validate_NotEmpty) to perform the not empty check.

  • 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. 2026-05-10T15:04:05+00:00Added an answer on May 10, 2026 at 3:04 pm

    I did it this way (ZF 1.5):

    $name = new Zend_Form_Element_Text('name'); $name->setLabel('Full Name: ')      ->setRequired(true)      ->addFilter('StripTags')      ->addFilter('StringTrim')      ->addValidator($MyNotEmpty); 

    so, the addValidator() is the interesting part. The Message is set in an ‘Errormessage File’ (to bundle all custom messages in one file):

    $MyNotEmpty = new Zend_Validate_NotEmpty(); $MyNotEmpty->setMessage($trans->translate('err.IS_EMPTY'),Zend_Validate_NotEmpty::IS_EMPTY); 

    hope this helps…

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

Sidebar

Related Questions

I'm using Zend_Form from Zend Framework 1.10.6 to render a html form. In this
I'm creating a form using Zend_Form, and all he words that contains diacritics are
i am using zend form and i have a condition such that: when i
This question is mainly geared towards Zend in PHP, although it certainly applies to
I would like to add a simple check box to my form: $element =
I'm using the Zend Framework and I'm about to hack up some of my
i have an element of type Radio in zend form . how can i
When I insert some data with Zend_Form to database with non a-z characters like
I'm using Zend_Cache_Core with Zend_Cache_Backend_File to cache results of queries executed for a model
I've created a 3 screen wizard using the Zend_Form_SubForm example from the online reference

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.