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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T21:02:49+00:00 2026-05-15T21:02:49+00:00

I am trying to get the Zend_Filter_Input to work as required on a simple

  • 0

I am trying to get the Zend_Filter_Input to work as required on a simple login form.

Here is my code

    $filters = array('username' => 'StringTrim', 'password'  => 'StringTrim');  
    $validators  = array( 
              'username' => array('Alnum', 'presence' => 'required'),
              'password' => array('Alnum', 'presence' => 'required')
    );

    $input = new Zend_Filter_Input($filters,$validators);

    print_r($input->getMissing());

and the response is this

Array
 (
    [username] => Array
    (
        [0] => Field 'username' is required by rule 'username', but the field is missing
    )

    [password] => Array
    (
        [0] => Field 'password' is required by rule 'password', but the field is missing
    )

  )

I am referred to the official docs. Why is it saying rule "username" and rule "password" here ?

Thanks

  • 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-15T21:02:50+00:00Added an answer on May 15, 2026 at 9:02 pm

    I’m the developer who designed and implemented Zend_Filter_Input in 2007.

    Each rule is identified by the associative array key. In your case you have two rules, “username” and “password”. If your input does not pass some of your rules, the error messages tell you which rules were not satisfied.

    Your rule names also happen to correspond to the names of the form fields you’re validating. By default, the field that a rule validates is the same as the rule name.


    Re your comment: You aren’t passing $_POST as data to validate. You must do either this:

    $input = new Zend_Filter_Input($filters,$validators,$_POST);
    

    Or else this:

    $input = new Zend_Filter_Input($filters,$validators);
    $input->setData($_POST):
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to get a filtering select work with a Dojo enabled form using
I am trying get Struts 2 and Tiles to work and I am using
Trying to get comfortable with jQuery and I have encountered some sample code that
I'm trying to make my custom filter work... I have the following code in
I'm trying to get code hinting in eclipse for zend in a non-Zend project.
I have a created a simple doctrine2/zend skeleton project and am trying to get
I am currently trying to get Xdebug to work on our development server. As
I am trying to get Propel to work in my Zend app, it seems
I'm trying to get my feet wet with the Zend Framework here. I'm following
I'm new to Zend framework and trying to get some insights about code re-usability.

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.