Skip to content
Snippets Groups Projects
Commit 887ef28a authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Fix bug in form panel related to container fields.

parent bc3d4aec
No related branches found
No related tags found
No related merge requests found
......@@ -33,6 +33,7 @@ Ext.define('App.form.Panel', {
'App.form.field.Dict',
'App.form.field.DictMultiDefault',
'App.form.field.List',
'App.form.field.TextPicker',
'Ext.form.field.Date',
'Ext.form.field.HtmlEditor'
],
......@@ -361,37 +362,53 @@ Ext.define('App.form.Panel', {
"use strict";
var combo,
field,
fields = [],
i,
items,
containers,
fields,
rec,
value;
function pushToFields(key, value) {
fields.push(value);
}
// get the list of dirty fields
items = this.getForm().getFields();
items.each(function (item, index, len) {
if (item.getXType() !== 'compositefield') {
fields.push(item);
}
});
// include dirty fields embedded in composite fields
items.each(function (item, index, len) {
if (item.getXType() === 'compositefield') {
item.items.eachKey(pushToFields);
//
// get the list of basic fields:
// those at the first level and those encapsulated in fieldset
//
// WARNING: do not use query(field) since it find all fields
// including those encapsulated in complexe field container
// which encapsulated grid with cell editing...
//
fields = this.query('> field');
fields = Ext.Array.merge(fields, this.query('fieldset > field'));
// get the list of field container:
// those at the first level and those encapsulated in fieldset
containers = this.query('> fieldcontainer');
containers = Ext.Array.merge(containers, this.query('fieldset > fieldcontainer'));
// container handles two type of object:
// - composite field merging several standard field
// - single field encapsulating complex widget grid with cell editing.
//
// the extraction the sub field structure depends on the type
Ext.Array.each(containers, function(el) {
// standard field container merging basic fields:
// retrieve all basic fields
if (el.getXType() === 'fieldcontainer') {
Ext.Array.each(el.query('> field'), function(field) {
fields.push(field);
});
// field container encapsulating complex object:
// treat it as a single field
} else {
fields.push(el);
}
});
// update the record
// take care of special treatment required by date and combobox
for (i = 0; i < fields.length; i += 1) {
Ext.Array.each(fields, function(field) {
field = fields[i];
value = field.getValue();
switch (field.getXType()) {
......@@ -424,6 +441,6 @@ Ext.define('App.form.Panel', {
}
record.set(field.getName(), value);
}
});
}
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment