0

Is it possible to create a structure like this on HTML ?

Companies-> (employee, payment, etc....); (employee, payment, etc....)

I know that I can create arrays in HTML to use them in PHP through POST... but is it possible to create an array inside of an array ?

And is it correct or there is a better way os of doing that ?

I am guessing that it would be something like this...:

<input name="Companies[employee[]]"/>
<input name="Companies[payment[]]"/>

PS: I can't use 2 diffent IDs or names because it's the User who decides how many entries the form will have.

6
  • 1
    You would save yourself a lot of trouble if you'd just limit the form to the entry of 1 person at a time. If you must add multiple people, create something like an CSV reader and have people enter their data in a spreadsheet. You could even create a Google Documents spreadsheet as input for your web application. (Ab)using forms to enter massive amounts of data is never a great user experience. Commented Oct 9, 2018 at 7:30
  • You can always make a complex form and then jsonize it and sent it to php then :) Commented Oct 9, 2018 at 7:31
  • 1
    <input name="Companies[employee][]"/> <input name="Companies[payment][]"/> Commented Oct 9, 2018 at 7:32
  • Yeah. Sometime if companies are more then he cann't go with company1 , company2 ..... etc like that right. It should be an array.. Commented Oct 9, 2018 at 7:38
  • @HenryvanMegen great tip I will use it in another view. Unfortunately at this one I've been forced to use the array inside of an array by the bussiness rules... And I also recommend the others to follow your answer! Commented Oct 9, 2018 at 7:44

1 Answer 1

2

Update your code as below.

<input name="Companies[employee][]"/>
<input name="Companies[payment][]"/>
Sign up to request clarification or add additional context in comments.

1 Comment

Try to explain your answer as it will helpful for others as well.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.