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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T16:19:30+00:00 2026-06-06T16:19:30+00:00

OK, so I come from an Flex/ActionScript back ground, since this field is slowly

  • 0

OK, so I come from an Flex/ActionScript back ground, since this field is slowly dieing I figure its time to move onto full time PHP.
Anyway, I think I have a pretty good understanding of the Zend framework(most places I worked for used it). However, they used it mostly just for the table abstract class so it really wasn’t a good MVC practice, more like just Model.
Going on interviews I almost always get asked where does the form validation happen.
Now I know zend has built in form validaters I am not talking about that.
I am talking about a standard HTML form built in a view and submitted to the server.

The question I want to know is, is it better done in the control or in the model.

And also why use zend_form at all, to me it seems like it would be hard for a designer to make it sexy.

  • 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-06T16:19:32+00:00Added an answer on June 6, 2026 at 4:19 pm

    If you are attaching validators to form elements the form is validated in the controller and can be checked using a simple if() loop:

    if($form->isValid($postData)) {
        //do some stuff
    }
    

    otherwise you can validate a simple html form or other input in the controller using Zend_Filter_Input :

    //set filters and validators for Zend_Filter_Input
        $filters = array(
            'id' => array('HtmlEntities', 'StripTags')
        );
    
        $validators = array(
            'id' => array('NotEmpty', 'Int')
        );
    
        //assign Input
        $input = new Zend_Filter_Input($filters, $validators);
        $input->setData($this->getRequest()->getParams());
    if ($input->isValid()) {
    //do some stuff
    }
    

    either way you want to do at least basic validation and filtering in the controller to try and prevent cross site scripting and sql injection.
    You can always do deeper validation and filtering in your domain models if required.

    As far as why use Zend_Form, it’s not as bad as it may first appear. The ability to attach validators and filters with custom messages is very useful to some people. The decorators while difficult in the beginning can put to good use with practice. Also you cheat and just use the viewScript() decorator (Like I usually do). The viewScript decorator provides a lot of control in more more familiar form.

    Here is an example:

    //The Form
    class Application_Form_Search extends Zend_Form
    {
        public function init() {
            $this->setMethod('POST');
            $this->setDecorators(array(
                array('ViewScript', array(
                        'viewScript' => '_searchForm.phtml'//the partial script used as a decorator
                ))
            ));
            // create new element
            $query = $this->createElement('text', 'query');
            // element options
            $query->setLabel('Search Keywords');
            $query->setAttribs(array('placeholder' => 'Artist or Title',
                'size' => 27,
            ));
            // add the element to the form
            $this->addElement($query);
    
            $submit = $this->createElement('submit', 'search');
            $submit->setLabel('Search Site');
            $submit->setDecorators(array('ViewHelper'));
            $this->addElement($submit);
        }
    }
    

    The Partial Script:

    <article class="search">
        <form action="<?php echo $this->element->getAction() ?>"
              method="<?php echo $this->element->getMethod() ?>">
            <table>
                <tr>
                    <th><?php echo $this->element->query->renderLabel() ?></th>
                </tr>
                <tr>
                    <td><?php echo $this->element->query->renderViewHelper() ?></td>
                </tr>
                <tr>
                    <td><?php echo $this->element->search ?></td>
                </tr>
            </table> 
        </form>
    </article>
    

    as you can see this would be much more familiar to code and much easier for a designer to style.

    Hope this helps, Good Luck…

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

Sidebar

Related Questions

i just checking Flash Builder 4 ( i come from Flex builder 3 ),
I come from a Visual Basic background (a long time ago), so be gentle
I come from frontend background, so I apologize if this db question seems dumb.
This is a pretty generic question, but I come from a few years with
I come from a mostly n-tier background, and I'm trying to move more towards
I come from an MVC background (Flex and Rails) and love the ideas of
I come from a world of c# were doing something like this is allowed.
I come from the Java world, so to me it's all object.foo() , but
I come from a Java background and am getting more into .NET, what are
I come from ruby/C# and am new to Python. I'm looking at the following

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.