PDA

View Full Version : Retrieving Form Value From Disabled Date Field in ExtJS 4.0.7



rkanemeier
17 May 2017, 10:27 AM
I have an application (I did not create it) that dynamically builds a form/panel/window based off an ajax request from a remote server (the remote server stores the field configs for the form). The app will build a date field (with date picker) in the form if the data type of the field is a date. This app will also "protect" fields if the field config tells it to do so. We are protecting the date field from input by setting style to disabled on the date field (see code below). However, whenever we getValues() for the form, the protected date field returns "undefined". I need to retrieve the value of disabled date fields, otherwise the server side programs/scripts will not function properly.



if (fields[j].DGVTYPE === 'DATE') {

var dateStyle = '';

// Set disabled style
if (dateDisabled) {
dateStyle = '{.x-form-item-default.x-item-disabled{opacity: 1 !important;}}';
}

form.add(Ext.create("Ext.form.field.Date",
{
xtype: 'datefield',
fieldLabel:this.sortedFields[j].DGVCOLUMN,
itemId:this.sortedFields[j].DGVFIELD,
name:this.sortedFields[j].DGVFIELD,
format: dateFormat,
disabled: dateDisabled,
maxWidth: 768,
minWidth: 400,
width: widthValue,
labelWidth: 150,
msgTarget: 'under',
editable: fieldEnabled,
enforceMaxLength: true,
validateOnChange: false, // needed or else the form will jump on validation
validateOnBlur: false, // needed or else the form will jump on validation
maskRe: maskRe,
maxLength: this.sortedFields[j].DGVLENGTH,
style: dateStyle
}));

}


The bottom line of what we need to accomplish is to protect the date field from input/data-entry, but still send the value of the date field back to the server script/program. I'm no where near being an expert on ExtJS syntax to determine how I would know what method / function to use to retrieve this value. Thanks in advance to anyone who can help.

SurenderBhyan1
17 May 2017, 8:21 PM
This is the basic behavior of html not to submit disable fields.

You can use a hidden field for the same and submit that.