PDA

View Full Version : JSON Formatting Issue



perkinsit
29 Sep 2009, 7:01 AM
I am new to ExtJS and have run into a problem I don't see addressed anywhere. When I create traditional web forms, outside of ExtJS, I use an array naming scheme to allow me to segment information based on its purpose and where it needs to be inserted. For instance, I might have a profile update form with the following fields:


First Name
Last Name
Email Address
Social Security #
Street Address
City
State
Zip

And I might use a naming scheme to separate the name from the address like:


contact[fname]
contact[lname]
contact[ss_num]
contact[email]
addr[street]
addr[city]
addr[state]
addr[zip]

This allows me to pass the entire $_POST array (yes, I use PHP) to the function, and then within the function I can use the different arrays within $_POST and loop through them to create my queries.

My question is this, I have a multitab form that I would very much like to segment the information on each form to be within its own container within a main JSON container, much like the multidimensional array I mentioned above. Is this just a matter of naming the fields within the form a certain way? Any help on this would be greatly appreciated.

Thanks!

29 Sep 2009, 11:04 AM
yes, try
you can try contact.fname, contact.lname, etc and try to use the json_decode to try to read them.

perkinsit
29 Sep 2009, 11:13 AM
Thanks for your reply. I just want to be clear. I have no problems getting the data in the form I need it from ExtJS to php (submits via $_POST) with AJAX, but when I try to load a record from the database and populate the form, the field names don't match up because the form shows, for instance, consumer[fname], but the field name from the database is named 'fname'. So when I use the loadRecord() function, none of the fields match, so nothing populates. I would like to be able to load the data, allow for edits, and then submit the data, all using the array naming scheme I mentioned before. Hope that helps, and thanks for your assistance!

29 Sep 2009, 11:15 AM
you need to work to make sure it matches.