Results 1 to 4 of 4

Thread: Checkbox value in form submitted as true/false instead of 1/0

  1. #1
    Sencha User
    Join Date
    Jul 2013
    Posts
    26
    Vote Rating
    0
      0  

    Default Checkbox value in form submitted as true/false instead of 1/0

    Hi,

    I have a form that includes a checkbox field and on form submit, I want the checkbox value as 1 or 0.
    The jsonSubmit is enabled for the form.
    The checkbox value is submitted as true or false instead of 1 or 0.
    I have specified the inputValue and uncheckedValue for the form.
    The value is submitted as 1 or 0 when jsonSubmit is disabled.

    How to solve this problem.

    Please help.

    Thanks

  2. #2
    Sencha - Engineering israelroldan's Avatar
    Join Date
    Nov 2011
    Location
    Tilburg, NL
    Posts
    354
    Vote Rating
    51
      0  

    Default

    Which Ext version are you using?
    Can you share your code?
    This seems to work fine: https://fiddle.sencha.com/#fiddle/4ni
    Israel Roldn | Software Engineer (Frameworks)

  3. #3
    Sencha User
    Join Date
    Jul 2013
    Posts
    26
    Vote Rating
    0
      0  

    Default

    I m using v4.2.1 . I get 1 or 0 with form.getValues().
    But on form.Submit() the value submitted is true or false.

    Right now I have overriden the checkbox's getValue() method to return the value as 1 or 0. Is it the right way to fix it or is there any config that I can set for the checkbox

  4. #4
    Ext JS Premium Member burnnat's Avatar
    Join Date
    Jun 2011
    Posts
    418
    Vote Rating
    64
      0  

    Default

    The inputValue and uncheckedValue configs only affect the submitted value if jsonSubmit is false, as you've seen. When jsonSubmit is enabled, it uses the getModelData() method of the field to get the data for submission. Normally I believe getModelData() calls getValue() to get the value, so I'm surprised overriding getValue() didn't do what you want. You can try overriding getModelData()directly, but failing that I would set a breakpoint in Ext.form.Basic.getValues() and then step through with a debugger to see where the value is coming from.

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
  •