I have a page where I need to submit an unknown number of objects with this structure:
object
name
phone
hours
monday
open
close
tuesday
open
close
...etc
I am trying to figure out how to use the name parameter on my html element to create these objects. The problem is, they do not necessarily have to have all of the attributes. Some may have phone numbers, some may not….same with the hours. Everything I have tried results in something like this
Array ( [params] => Array ( [service[name] => Array ( [0] => service5 [1] => service5 ) [service[phone] => Array ( [0] => 1234 [1] => 12345 ) ) )
Is there any way to do this?
UPDATE: The only way I have been able to come up with is to figure out a way to use an index like this:
params[service][1][name]
I will have to use javascript to generate/update that index anytime an object is added or removed from the page…
Is there any way to achieve this object packaging dynamically? Thanks!
Using javascript you can pull all the values and generate a JSON string, the send that to the server and maintain your layered type array.