PDA

View Full Version : HTML5 doctype textfield sends "," (comma) in empty textfields strings



maneljn
11 Apr 2013, 5:57 AM
extjs 4.2
<!DOCTYPE html>

I'm upgrading from a extjs 4.1.1.a application and doctype HTML4
My surprise is that when i change to doctype HTML5, the textfields that i leave empty in a form are sended via POST like this value "," (a string containing one comma character)

How it's possible this ?

maneljn
11 Apr 2013, 8:13 AM
I have nested form panels, with some textfields with the same "name"
With extjs 4.1.1.a and HTML 4 i have no problem with it.
Could it be a problem with Extjs 4.2 or HTML 5 ??

maneljn
16 Apr 2013, 1:49 AM
This could be the explanation about nested forms changes in extjs 4.2 ?

In Extjs 4.1.1the form basic getValues() has this implementation



/** * Retrieves the fields in the form as a set of key/value pairs, using their * {@link Ext.form.field.Field#getSubmitData getSubmitData()} method to collect the values. * If multiple fields return values under the same name those values will be combined into an Array. * This is similar to {@link Ext.form.Basic#getFieldValues getFieldValues} except that this method * collects only String values for submission, while getFieldValues collects type-specific data * values (e.g. Date objects for date fields.) * * @param {Boolean} [asString=false] If true, will return the key/value collection as a single * URL-encoded param string. * @param {Boolean} [dirtyOnly=false] If true, only fields that are dirty will be included in the result. * @param {Boolean} [includeEmptyText=false] If true, the configured emptyText of empty fields will be used. * @param {Boolean} [useDataValues=false] If true, the {@link Ext.form.field.Field#getModelData getModelData} * method is used to retrieve values from fields, otherwise the {@link Ext.form.field.Field#getSubmitData getSubmitData} * method is used. * @return {String/Object} */ getValues: function(asString, dirtyOnly, includeEmptyText, useDataValues) { var values = {}, fields = this.getFields().items, f, fLen = fields.length, isArray = Ext.isArray, field, data, val, bucket, name; for (f = 0; f < fLen; f++) { field = fields[f]; if (!dirtyOnly || field.isDirty()) { data = field[useDataValues ? 'getModelData' : 'getSubmitData'](includeEmptyText); if (Ext.isObject(data)) { for (name in data) { if (data.hasOwnProperty(name)) { val = data[name]; if (includeEmptyText && val === '') { val = field.emptyText || ''; } if (values.hasOwnProperty(name)) { bucket = values[name]; if (!isArray(bucket)) { bucket = values[name] = ; } if (isArray(val)) { [B] values[name] = values[name] = bucket.concat(val); } else { bucket.push(val); } } else { values[name] = val; } } } } } } if (asString) { values = Ext.Object.toQueryString(values); } return values; },

The same method in extjs 4.2 has this change in red painted line.



values[name] = bucket.concat(val);

how this change affects the behavior of the method ???


Also the method getFields() has been recoded

In Extjs 4.1.1



/** * Return all the {@link Ext.form.field.Field} components in the owner container. * @return {Ext.util.MixedCollection} Collection of the Field objects */ getFields: function() { var fields = this._fields; if (!fields) { fields = this._fields = new Ext.util.MixedCollection(); fields.addAll(this.owner.query('[isFormField]')); } return fields; },

In Extjs 4.2



/** * Return all the {@link Ext.form.field.Field} components in the owner container. * @return {Ext.util.MixedCollection} Collection of the Field objects */ getFields: function() { return this.monitor.getItems(); },