View Full Version : form.load Question related to XMLReader

5 Jan 2013, 3:48 PM
Just Purchased Architect and am creating my first restful form app. I was successful in create a form with a data grid and proved that the crud functionality works as advertised ( I love Architect!) now I am creating a form panel with fields named from a model that will sync detail records in a grid Panel. But first the form so...

I have defined a model, a restProxy for the model and an xml reader for the proxy. Data is returned no problem but now I have a couple of questions as follows:

1. Can a form be populated using the xml reader and a formPanel.load or formPanel.loadRecord method?

2. If so do all the fields that are in the model have to be present on the form or can I just pick and choose which fields that will be on the form.

Thanks in advance!

6 Jan 2013, 7:17 AM
If you look at the source for Ext.form.Basic.loadRecord(), here's what it does:

loadRecord: function(record) {
this._record = record;
return this.setValues(record.data);

In context, "this" is just Ext.form.Basic, so what it's ultimately doing is throwing all key/values pairs found in record.data at the form and trying to apply the key values to any matching fields that have the same "name" as the keys in the record.

So to answer, #2, all fields in the record do not have to be present in the form. However, if you are updating the record based on the form fields (e.g., opening a window with a form, modifying values, and then setting the record's data from the form on a "save" button click), any fields in the record that are not in the form will not get updated. There is nothing, though, that will break if you simply throw a record at a form that only contains fields that partially correlate to the record.

On #1, sure, why not? If your read has successfully created model instances from your proxy results, populating a form from one of those models should be no problem at all.

6 Jan 2013, 7:55 AM
Thanks, Makes sense now, appreciate your help.