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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T06:15:16+00:00 2026-05-30T06:15:16+00:00

I have an issue where I cannot seem to get the values to re-populate

  • 0

I have an issue where I cannot seem to get the values to re-populate the zend form. I am using the form a bit different that what I am used to.

I have broken the ‘social security number’ into three fields, the values come out as an array, but I cannot get them to go back in after the operation.

This is my form class:

class Application_Form_Checkssnforexistingreferral extends Zend_Form {
    public function init() {

        // SSN
        $this->addElement('text', 'ss_number', array(
                'label' => 'SSN: ',
                'required' => True,
        ));

    }
}

Then in my view I use the form like so…

<?php // SSN (first segment)
                            echo '<p>Social Security Number</p>';
                            echo $this->formText('ss_number["first"]', '', array(
                                'size' => 3, 
                                'maxlength' => 3,
                                'required' => True,
                                'id' => 'ssn1',
                                )) 
                            ?>
                        <span>-</span>
                        <?php // SSN (second segment) 
                            echo $this->formText('ss_number["second"]', '', array(
                                'size' => 2, 
                                'maxlength' => 2,
                                'required' => True,
                                'id' => 'ssn2',
                                )) 
                            ?>
                        <span>-</span>
                        <?php // SSN (third segment) 
                            echo $this->formText('ss_number["third"]', '', array(
                                'size' => 4, 
                                'maxlength' => 4,
                                'required' => True,
                                'id' => 'ssn3',
                                )) 
                            ?>

I did it like this so that I may have greater control over the styling and presentation of the form elements, it works quite well on a larger form, although I am having issues populating the fields on that one too.

Here is what I am attempting in the controller…

if ($this->getRequest()->isPost()) {
            $formData = $this->getRequest()->getPost();
            if ($form->isValid($formData)) {



                $referralsModel = new Application_Service_Findssninreferrals();
                $referrals = $referralsModel->findSocialSecurityNumber($formData);

                // load the view's parameter 'referral' w/ the object collection
                // and 'NULL' the 'first page load' parameter
                $this->view->referrals = $referrals;

                $first = $formData['ss_number']['"first"'];
                $second = $formData['ss_number']['"second"'];
                $third = $formData['ss_number']['"third"'];

                $form->populate(array('ss_number["first"]' => $first,
                                      'ss_number["second"]' => $second,
                                      'ss_number["third"]' => $third
                            ));
                if (empty($referrals)) {
                    $flashMessenger->addMessage('There is no record found for this SSN, you may create a new referral for this client');

                    print_r($formData);
                    $form->populate(array($formData['ss_number']));

                    $ssn = $first . $second . $third;
                    $this->view->continueLink = "link to create new referral" . $ssn;
                    } 

            } else {
                      // else populate the form and allow the correction of...
                      $flashMessenger->addMessage('There was a problem with the number that you entered, please try again...');
                      $form->populate($formData);
                   }

            }
            $this->view->form = $form;

…

this is how one of the elements renders as HTML…

<p>Social Security Number</p>
<input type="text" required="1" maxlength="3" size="3" value="" id="ssn1" name="first" class="idleField">

In the controller, the ‘if(emtpy($referrals))’ section is where I was doing most of the experimenting trying to get it to repopulate the fields. The section above does not work either, I basically attempted to just to a ‘form->populate(array(…’ but with no luck either. I am just not getting anything from the ‘populate’ method…

  • 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-30T06:15:17+00:00Added an answer on May 30, 2026 at 6:15 am

    Try redirecting to the requesting url should take you right back with form populated. Otherwise this probably won’t work, you can’t populate the form without a request (could use ajax) and you don’t have a new request after the post. This one action should probably be at least 2 actions, however
    you can try it this way:

     if ($this->getRequest()->isPost()) {
                $formData = $this->getRequest()->getPost();
                if ($form->isValid($formData)) {
    
                    $referralsModel = new Application_Service_Findssninreferrals();
                    $referrals = $referralsModel->findSocialSecurityNumber($formData);
    
                    // load the view's parameter 'referral' w/ the object collection
                    // and 'NULL' the 'first page load' parameter
                    $this->view->referrals = $referrals;
    
                    $first = $formData['ss_number']['"first"'];
                    $second = $formData['ss_number']['"second"'];
                    $third = $formData['ss_number']['"third"'];
    
                    if (empty($referrals)) {
                        $flashMessenger->addMessage('There is no record found for this 
                            SSN, you may create a new referral for this client');
    
                        $this->_redirect($this->getRequest()->getRequestUri());
                        //next line may or may not be needed or help
                        $form->populate($formData);
    
                        $ssn = $first . $second . $third;
                        $this->view->continueLink = "link to create new referral" . $ssn;
                    }
                } else {
                    // else populate the form and allow the correction of...
                    $flashMessenger->addMessage('There was a problem with the number that you entered, please try again...');
                    $form->populate($formData);
                }
            }
            $this->view->form = $form;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an issue that is driving me a bit nuts: Using a UserProfileManager
I have an issue using the Dynamic Expression API. I cannot seem to compare
I have a database issue that i currently cannot wrap my head around with
So I'm having two issues that I cannot seem to get unkinked. I run
Just hit a very odd issue with databinding which I cannot seem to get
I have issue that is reproduced on g++. VC++ doesn't meet any problems. So
We have an issue using the PEAR libraries on Windows from PHP . Pear
I have an issue with using AWK to simply remove a field from a
Maybe I am just forgetting something, but I cannot seem to get NUnit to
I have an issue where a program that runs fine under windows xp has

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.