Results 1 to 4 of 4

Thread: Radiofield does not allow for boolean fields

    You found a bug! We've classified it as TOUCH-4610 . We encourage you to continue the discussion and to find an acceptable workaround while we work on a permanent fix.
  1. #1
    Sencha User
    Join Date
    Apr 2013
    Posts
    10
    Vote Rating
    0
      0  

    Default Radiofield does not allow for boolean fields

    Bug:

    Radio buttons cannot have the value false; because they check for a falsy value instead of an undefined value, they never return the correct value when queried (eg with #getGroupValue.)

    That is, if the declared value of a radio button is false, the radio button will respond with nil when queried for its value. The effect (and visible indicator of the bug) is that, when a form is displayed and the value of the record's corresponding attribute is false, the checkbox with value=false will never be checked when you open the form.

    It's maybe easier to see the bug in the code.

    Code with bug:

    radio.js line 66:

    Code:
        getValue: function() {
            return (this._value) ? this._value : null;
        },
    Fix:

    Code:
        getValue: function() {
            return (typeof this._value === 'undefined') ? null : this._value;
        },


    Use case:

    In my app, we have a boolean field, "is_private". But we want to display the field to the user as a set of radio buttons, one with the label "Public" and the value false, and the other labelled "Private" and the value true. With this bug, the form would never display a false value for the attribute. Even if 'private' is false, neither radio button would be checked when opening the form.

  2. #2
    Sencha User
    Join Date
    Apr 2013
    Posts
    10
    Vote Rating
    0
      0  

    Default

    Interestingly, this same line in the getValue() function has been bug-reported and fixed once before. Previously it did not work with any values. The fix made it work with all values except booleans: http://www.sencha.com/forum/showthread.php?200708

  3. #3
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,553
    Vote Rating
    1272
      0  

    Default

    Thanks for the report! I have opened a bug in our bug tracker.

  4. #4
    Sencha User
    Join Date
    Apr 2013
    Posts
    10
    Vote Rating
    0
      0  

    Default

    Bump.A year later, fix appears to not be implemented yet. Every time I update sencha touch I have to re-implement this (and other) fixes.This fix is straightforward, the code for the fix is there. The use case having two radio buttons, one with "true" and one with "false" as the value, seems pretty clear.

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
  •