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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:21:48+00:00 2026-05-26T01:21:48+00:00

I am modifying a form component that is part of a web application to

  • 0

I am modifying a form component that is part of a web application to support users adding and removing extra form fields during run time.

The data from the form is setted to a php object when the form is submitted:

<?php
   class users {
     public function setName($name){
         (...)
     }

     public function getName(){
         (...)
     }

     public function setSomeAttribute($name){
         (...)
     }

     public function getSomeAttribute(){
         (...)
     }
   }

The form is generated like so:

$form = new Form();
$form->addField('Text', 'Name', (... some other parameters...))
->addField('Address', 'SomeAttribute', (... some other parameters...));

A view is generated containing a tree of objects representing each field (some “fields” such as addresses can contain child fields such as text inputs.

Given that we know the name of the object property, the form component can then easily bind the result of that form field to the respective object property using getters and setters.

The issue I am facing now is this: I need to allow the user to add fields during run time. This will work using Jquery and also fallback for users without javascript.

Assuming we have a page where the user can edit his profile and add multiple shipping addresses. He will have a button that says “add address”. Clicking this button would doe the following:

  • For users with javascript enabled, the user will immediately see a new “address field” which consists of a few dropdowns and text fields added.
  • For users without javascript enabled, the page will refresh, and the new “address field” which consists of a few dropdowns and text fields added.

What is the best way to let the PHP side know that these new fields exist and we need to get the posted data from them?

  • 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-26T01:21:49+00:00Added an answer on May 26, 2026 at 1:21 am

    all form elements will be submitted in the request and available to PHP. so you just need to refer to the elements using whatever name the elements were assigned in the form.

    for the country for 2 addresses you’d want to name elements like “addr_1_country”, “addr_2_country”, or alternately “addr_country[]” for both to make the values available in an array. if you use the former, you could loop thru the names “addr_$i_country” until you find them unset (or get JQuery to update a count value that also gets submitted, like “addr_count” that tells you how long to loop).

    either way you just need to know the names. but if you can only specify “Addresses” and/or the child fields are given names that you cannot assign yourself then you might have a problem. maybe your “->addField()” is smart enough to name the them for you. otherwise update “Form” to name automatically or accept ‘name’ args.

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

Sidebar

Related Questions

I'm modifying an existing web application that features the ability to administrate users who
We all know that modifying a .NET web application's web.config file restarts the app
I am modifying a php login form, adding javascript check form function to it.
I'm modifying an application written in C# that makes heavy-use of multi-threading to play
I'm currently trying to make a form called countcash that allows users to input
I'm modifying Python code that have this form: def foo(self): try: connect socket except
Ive been modifying a form today, and testing it in Chrome. I noticed that
I'm modifying a mature CGI application written in Perl and the question of content
I am modifying some code and came across a declaration that I am having
I am modifying a Nant build script to run some unit tests. I have

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.