checkbox return off

  • Does the Ext.form.CheckBox do something like return a value of "off" when the user uncheck it? the original html checkbox returns nothing, which is really a bad design.


  • Some may consider it bad design, but not returning a value is standard behavior for an unsuccessful form control. In the case of a checkbox, it's not considered successful unless it's checked. So, checked checkboxes result in name/value pairs sent to the server while unchecked don't. If you know that, handling it server-side is painfully simple and straightforward.

    Now, how this relates to Ext. Standard Ext checkboxes return a value of "on" if they're successful. If they are not, they do as they should just like standard HTML checkboxes and return nothing. Now, personally, I don't like checking the value of a string server-side, so a simple tweak was to specify what the value ought to be, in my case 1.

    In closing, in my opinion Ext treating the checkbox differently than the HTML checkbox with what is considered successful/unsuccessful and what to do in each of those cases is a bad idea.


  • You may want to try http://extjs.com/forum/showthread.php?t=25924.

    BTW, I also think that not sending unchecked value to the server was not good design decision. It makes automation at backend more complicated. One old math professor taught us that zero is number and not "nothing" so here it is same unchecked checkbox has state of "off", not nothing... Just my 2 cents...


  • Saki

    thanks for that wonderful contribution. I will try it out.

    as for the debate on whether the standard html checkbox is a good design, I posted somewhere else to find out what people are doing to get around the non-returned uncheck. what I found out is that people are adding on a hidden checkbox, with javascripts which turns on the hidden checkbox, and force it to return the "off" value. that being the case, it make total sense that Extjs package all that in as a design option. it would be of service to many folks filling in javascripts themselves. for those who are die hard standard watchers. they can simply ignore the option.

    other wise, if I may ask, are we expect to simply not use checkbox for boolean form fields? like stick to a pair of radios for true/false?


  • yes, I know. your extension works just the way I was looking for. it even changes the input value to true/false instead of on/off, another measure of convenience.

    Thanks.


  • Well, my opinion of checbox logic is "materialized" in XCheckbox extension. I just do not want to handle the problem at backend.







  • #If you have any other info about this subject , Please add it free.#
    Your name:
    E-mail:
    Telphone:

    Your comments:


    If you have any other info about checkbox return off , Please add it free.

    7 January 2009 | cameltoepants.com | edit