Results 1 to 9 of 9

Thread: Form submits empty textfield

  1. #1

    Default Form submits empty textfield

    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.



    MyCodeBase.txt

  2. #2

    Default

    I have tried by setting submitEmptyText:false during form submit. However it didnt work.

    Please help me in solving this issue.

  3. #3
    Sencha User friend's Avatar
    Join Date
    Apr 2011
    Posts
    895
    Answers
    106

    Default

    Ensure that all of your form fields have a name attribute with a valid/unique name for each field.

  4. #4

    Default

    Quote Originally Posted by friend View Post
    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?

  5. #5
    Sencha User carol.ext's Avatar
    Join Date
    Jun 2007
    Location
    Littleton, Colorado, USA
    Posts
    707
    Answers
    25

    Default

    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.

  6. #6
    Sencha User friend's Avatar
    Join Date
    Apr 2011
    Posts
    895
    Answers
    106

    Default

    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.

  7. #7

    Default

    Quote Originally Posted by carol.ext View Post
    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.

  8. #8

    Default

    Quote Originally Posted by friend View Post
    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'
    },

  9. #9
    Sencha User
    Join Date
    Feb 2012
    Location
    Davenport, IA
    Posts
    30
    Answers
    2

    Default

    try adding a Writer that has a property with "writeAllFields" set to false
    Code:
    writer: {
      type: 'json',
      writeAllFields: false,
      root: 'data'
    }

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •