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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T21:51:18+00:00 2026-06-04T21:51:18+00:00

I have been attempting to create a form where a user can simply press

  • 0

I have been attempting to create a form where a user can simply press a button and the form will add a new field for the user to use. I have 2 of these dynamically added field types.

Firstly a field where a user can upload files, by pressing the add button another field is pasted underneath the current field and is ready for use.

I have followed an old guide on how to get this done with a bit of ajax and jQuery.

This guide to be exact: http://www.jeremykendall.net/2009/01/19/dynamically-adding-elements-to-zend-form/

As you can see it’s from 2009 and a bit outdated yet it still works under the current Zend Framework version 1.11.11

The problem however arises now that i want an edit / update version of the form. I need to populate it’s fields but first of all i need to create enough fields for the data to be stored in. So when there’s 3 files that have been uploaded it should create 2 additional fields and place the 3 file names in these fields ready to be edited and updated. Simply using $form->populate($stuff) is not going to work

I just have no idea how to accomplish this and the tutorial on dynamically added fields only goes as far as the addAction and not how to create the editAction under these conditions.

Is there any tutorial out there on how to create and manage forms such as these? I’m sure i am not the only one who’s had the idea to builds these kind of forms?

I can add my code if there’s a request for it but it’s the same as the example from the guide, just a different set of elements in the form.

Adding a small example of it’s use.
A user adds an item with 3 files, these files are uploaded along with a filename so in the database it appears like this : File_Id : '1' , File_Name : 'SomeFile' , File_location : 'somewhere/on/my/pc/SomeFile.txt'.

Now the user realizes he forgot a file or wants to delete a file from that list, he goes to the edit page and here i want the form to display the previously added filenames. So if there’s 3 files it shows 3 and when there’s 2 it shows 2 etc. How do i build a form to dynamically add fields based on the number of uploaded files and then populate them?

Any advice on how to handle this is well appreciated 🙂

  • 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-04T21:51:19+00:00Added an answer on June 4, 2026 at 9:51 pm

    You can make use of the semi-magic setXxx() methods of the form.

    Inside the form:

    public function setFiles($files) {
        foreach ($files as $file) {
            $this->addElement(/* add a file element */);
            //do other stuff, like decorators to show the file name, etc.
        }
    }
    

    In your controller:

    $files = $model->getFiles();
    $form = new Form_EditFiles(array('files' => $files));
    

    By passing an array with key files you will make the form try to call the method named setFiles(), which you have conveniently provided above.

    This should push you in the right direction, or so I hope at least.

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

Sidebar

Related Questions

I have been attempting to have a object that I can use across multiple
I have been attempting to enhance my GUI system written in Java to use
I have been attemptng to create a DLL with C/C++ that can be accessed
I have been attempting to enhance my GUI system written in Java to use
I'm attempting to create a new forum on an existing forum. I can create
I am new to both Silverlight and WP7. I have been attempting to hotlink
I have been trying to create a new file inside of my application support
I have been attempting to create a timer for my game and I heard
I have been attempting to create a Windows Application using Iron Ruby Version 1.1
I've been attempting to create a customized plus button in WPF. I only want

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.