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

  • Home
  • SEARCH
  • 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 8955041
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:27:14+00:00 2026-06-15T14:27:14+00:00

I’m using Zend Framework 1.12, making a page which have multiple forms in it.

  • 0

I’m using Zend Framework 1.12, making a page which have multiple forms in it. I use a single master form and subforms in it. Therefore, I have just one Validation code part.
These subforms point to different tables in database. Aim is that, if there is a row in database about that form, form should take values from database as default, to give user chance of change that data. And if there is not a row in database, input of this form will be inserted to db.
At first, I can take values from db and show them as values of form elements. But when I change it and try to take values with

$form->getValues();

I cannot access the values entered (or edited) in page, I just re-access the values in database which was put in form as default. This form should be able to edit always, and I have multiple forms for different kinds of data, which will do same thing too. What must I be doing wrong ? Any idea?

(addition) here is a summary of the relevant piece of my controller code:

$masterform = new Application_Form_GeneralForm(); // a class which extends Zend_Form
$form1 = new Application_Form_SmallForm(); // a class which extends Zend_Form_Subform
$masterform->addSubform($form1, 'form1');
                         // so far, for form 1, no problem. My second form will be 
                         // added to the masterform after this first form is submitted,
                         // which works fine.

$form2 = new Application_Form_AnotherSmallForm(); // a class which extends Zend_Form_Subform

$request = $this->getRequest();
if ($request->isPost()){
    if ($generalform->isValid($request->getPost())) {
         $form2->loadValues(); // the part that form elements are filled with data 
                               // taken from db, a method defined in `AnotherSmallForm` 
                               // class. Just assigning values to elements with `setValue()`

         $form2->saveValues(); // Here is the problem, another method to save the 
// current values to db. (defined in form class). I have to do this in this fragment of code, so i don't know to 
// use which order ( saveValues() and loadValues() methods' order )` 

         $masterform->addSubform($form2, 'form2');
    }
}

So, 1st step: $form1 is added to $masterform.

2nd step: $masterform submitted (it only includes $form1 now), then $form2 is added to $masterform. before it is added, the values for $form2 is loaded inside form elements.

3rd step: $masterform submitted, (so is $form1 and $form2). If any change of the values in $form2 , they must be updated in db by this submission.

This is goal of this code, which could not be accomplished because of 3rd step.

  • 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-15T14:27:15+00:00Added an answer on June 15, 2026 at 2:27 pm

    I finally figured it out. Even if subforms are created in conditions respect to each other, they should be created out of the if($request->isPost()) condition block. So, if you have to add them with steps (like I have to do it, $form2 created after $form1 is submitted, and $form1 remains in page), you should test if their requirements are satisfied directly and individually. This approach of mine does not work. It should be like this:

    $masterform = new Application_Form_GeneralForm(); 
    $form1 = new Application_Form_SmallForm();
    $masterform->addSubform($form1, 'form1');                          
    
    $form2 = new Application_Form_AnotherSmallForm(); 
    
    if (/* the requirement you want to check if $form2 should be added or not, 
        and this could easily be checking some value which is submitted with 
        $form1, so you have already checked if $form1 has been submitted */ ) 
        $masterform->addSubform($form2, 'form2'); // we add it if requirement is met
    
    $request = $this->getRequest();
    if ($request->isPost()){
        if ($generalform->isValid($request->getPost())) {
             $form2->saveValues(); // be sure it saves the final values added to form
             ////.......
        }
    }
    

    and, I stopped having loadValues() here, and I call that method inside the init() method of form class. So, as konradwww said, saveValues() should happen first, and loadValues() next. This could done by using the loadValues() in form class, it belongs to the process of initiation of the form anyway.

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

Sidebar

Related Questions

I have a text area in my form which accepts all possible characters from
I'm making a simple page using Google Maps API 3. My first. One marker
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am trying to understand how to use SyndicationItem to display feed which is
I have an autohotkey script which looks up a word in a bilingual dictionary
I have an array which has BIG numbers and small numbers in it. I
I have thousands of HTML files to process using Groovy/Java and I need to
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example

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.