PDA

View Full Version : Form submits empty textfield



Suresh.Natarajan
24 Apr 2012, 3:42 AM
Hello All,

I have a search form with 7 fields - 1 text field, 4 combo, 2 date fields). The layout is table (3 columns). The results have to be populated in a grid, once search succeeds. I am able to get the results, however I face the below problems:
Problem:
1. When I do a form submit without entering any values in these fields, the text field is going as empty and search query is failing.
2. Even if I select or enter values for any of the fields, the form submits only with the text field.

Please help me in solving this issue.


34443

Suresh.Natarajan
24 Apr 2012, 4:38 AM
I have tried by setting submitEmptyText:false during form submit. However it didnt work.

Please help me in solving this issue.

friend
24 Apr 2012, 4:57 AM
Ensure that all of your form fields have a name attribute with a valid/unique name for each field.

Suresh.Natarajan
24 Apr 2012, 6:20 AM
Ensure that all of your form fields have a name attribute with a valid/unique name for each field.

Thank you that solved half of my problem.
But still when I submit my form without entering any values to any of the fields, I am getting an empty string from the text field alone. I have to additionally check for the empty and frame my query. Does submitEmptyText: false will not work?

carol.ext
24 Apr 2012, 7:23 AM
Since you have not posted any code I am not sure if you are talking about empty string ("") or the emptyText configured for fields in your form.



emptyText : String

The default text to place into an empty field.

Note that normally this value will be submitted to the server if this field is enabled; to prevent this you can set the submitEmptyText option of Ext.form.Basic.submit to false.

friend
24 Apr 2012, 8:59 AM
If you're calling form.load({...}) prior to displaying the form, make sure that you're specifying a null as the initial value of the textfield. If you pre-initialize a textfield and a user enter no value for the field, it will POST an empty String as well.

If you don't initialize a textfield in any way, it should POST a null by default.

Suresh.Natarajan
24 Apr 2012, 9:21 AM
Since you have not posted any code I am not sure if you are talking about empty string ("") or the emptyText configured for fields in your form.

Thank you. I have added the code as an attachment (MyCodeBase.txt). Please take a look.
Also, I have tried the option submitEmptyText: false while submitting the form. However it didnt work for me.

Suresh.Natarajan
24 Apr 2012, 9:26 AM
If you're calling form.load({...}) prior to displaying the form, make sure that you're specifying a null as the initial value of the textfield. If you pre-initialize a textfield and a user enter no value for the field, it will POST an empty String as well.

If you don't initialize a textfield in any way, it should POST a null by default.

This is how, I add the text field to the form. I am not initializing anywhere. Am I doing something wrong here:

items: [
{
xtype: 'textfield',
name: 'TICKET_ID',
minLength : 6,
maxLength : 8,
regex: /[0-9]+/,
margin: '10 0 10 10'
},

WillFM
24 Apr 2012, 10:58 AM
try adding a Writer that has a property with "writeAllFields" set to false


writer: {
type: 'json',
writeAllFields: false,
root: 'data'
}