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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:44:25+00:00 2026-05-22T16:44:25+00:00

Using MVC architecture (Zend Framework), should you use a single view with if statements

  • 0

Using MVC architecture (Zend Framework), should you use a single view with if statements to display/process a form, or multiple views (i.e. one view to display form, one to display result).

In this instance, I am trying to produce a google like search engine. The layout of the page will fundamentally change when displaying search results.

For example; Controller:

public function indexAction()
    {
        if (!$this->getRequest()->isPost()) {
            // display form
        } else {
            if ($this->_request->isPost()) { 
                if (!$form->isValid($formData)) {
                    // re-display form with errors
                } else { 
                    // process form and;
                    // display result using same action/view?
                    // display result using same action but use a different view?
                } 
            }
        }
    }

Using the same view:

<?php if(isset($this->form)) : ?>
    <!-- show form -->
<?php else: ?>
    <!-- show result -->
<?php endif; ?>

Hope that makes sense.

  • 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-22T16:44:26+00:00Added an answer on May 22, 2026 at 4:44 pm

    Don’t get caught up in the old monolithic style of coding where one hunk of code does everything for one output page. The whole point of MVC is so separate responsibility. Think of a view as a template for a single piece of output, regardless of what page/url it appears on. The form is one piece of output. The search results is another. Use two views.

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

Sidebar

Related Questions

If we develop a winform app using an MVC architecture, it should not be
Using win forms with an MVC / MVP architecture, I would normally use a
I am using a Cairngorm MVC architecture for my current project. I have several
I'm using MVC, I've got a search page, and I want to pass multiple
I am using ASP.NET MVC architecture.I have a telerik window on a button click,
i'm using Asp.net MVC with Sharp Architecture. I have this code: return _repositoryKeyWord.FindAll(x =>
I can't get my application to work using MVC architecture. Here is the code:
I have been using an Object-Oriented MVC architecture for a web project, and all
Where in an MVC based architecture should the date formatting (long/short/time/no-time/UK/US) live? I want
I'm creating site using MVC architecture and get stunned when I came to AJAX.

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.