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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T03:05:55+00:00 2026-05-17T03:05:55+00:00

This might sound like an odd scenario, but I’ve got two forms on one

  • 0

This might sound like an odd scenario, but I’ve got two forms on one page. One is just posting back to itself. I made the second post to another action to keep the code cleaner. Maybe not the right choice…

The problem I’m having now is that if that second form doesn’t validate, I redirect back to the page with the form but I don’t know how to keep my form fields filled in with the original information the user entered. Is there a way to do that and keep posting to two separate actions, or do I need to just bite the bullet and have both forms post back to the same action and deal with the messy logic?

  • 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-17T03:05:56+00:00Added an answer on May 17, 2026 at 3:05 am

    I would submit both forms to the same action. There really shouldn’t be anything too messy about it. In each form include a hidden field to signify which form is being submitted.

    Application_Form_Login:

     /* other form elements */
     $this->addElement('hidden', 'login', array(
          'value' => 1
     ));
    

    Application_Form_Register:

     /* other form elements */
     $this->addElement('hidden', 'register', array(
          'value' => 1
     ));
    

    Controller:

    $loginForm = new Application_Form_Login();
    $registerForm = new Application_Form_Register();
    
    if($this->_request->isPost()) {
         if($this->_request->getPost('login')) {
             if($loginForm->isValid($this->_request->getPost())) {
                 // validated, redirect
                 $this->_helper->redirector('profile', 'user');
             }
         }
         if($this->_request->getPost('register')) {
             if($registerForm->isValid($this->_request->getPost())) {
                 // validated, proceed as needed
             }
         }
    }
    
    $this->view->loginForm = $loginForm;
    $this->view->registerForm = $registerForm;
    

    View:

    echo $this->loginForm;
    
    echo $this->registerForm;
    

    With this type of a setup, if either of your forms fail validation, isValid() will preserve any data that has been entered and you still redirect on a successful validation of one or both of the forms.

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

Sidebar

Related Questions

This might sound like a little bit of a crazy question, but how can
This might sound like a stupid question, but google didn't help me. Is there
This might sound like a strange question, but bear with me... I have a
This might sound like a bit of a silly question but I been looking
this might sound like a stupid question, but i want to clarify a concept:
This might sound like a noob question, but here it goes anyway. Can BlackBerry
This might sound like a trivial question, but it is rather important for consumer
I know this question might sound a little cheesy but this is the first
This might seem like a stupid question I admit. But I'm in a small
This might be on the discussy side, but I would really like to hear

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.