Unexpected behavior for checkbox and SHtml.onSubmitBoolean handler

26 views
Skip to first unread message

Denis Nevmerzhitsky

unread,
Dec 7, 2011, 5:36:42 PM12/7/11
to lif...@googlegroups.com
Hi!

I have simple CssSel:
"@domain-choose" #> SHtml.onSubmitBoolean(RV.domainChoose(_))

After submitting form domainChoose contains false, but checkbox was checked.
While investigating the sources i found the reason is Helpers.toBoolean and default value of checked checkbox - "on":
      case s : String => {
        val sl = s.toLowerCase
        if (sl.length == 0) false
        else {
          if (sl.charAt(0) == 't') true
          else if (sl == "yes") true
          else toInt(s) != 0
        }
      }

So default checked value is converted to false. I think "on" should be converted to true as well.

P.S. IMHO it is very strange toBoolean behavior for Strings, my usual is "false","off","no","0","" are false, others are true. Is there some specification for such conversion?

David Pollak

unread,
Dec 8, 2011, 12:49:24 PM12/8/11
to lif...@googlegroups.com
Please open a ticket for "on" (http://ticket.liftweb.net you must be a watcher of the LiftWeb space on Assembla)

In terms of the behavior, defaulting to false unless there's a good reason to be true seems like the right behavior to me.

--
Lift, the simply functional web framework: http://liftweb.net
Code: http://github.com/lift
Discussion: http://groups.google.com/group/liftweb
Stuck? Help us help you: https://www.assembla.com/wiki/show/liftweb/Posting_example_code



--
Visi.Pro, Cloud Computing for the Rest of Us http://visi.pro
Lift, the simply functional web framework http://liftweb.net


Denis Nevmerzhitsky

unread,
Dec 8, 2011, 1:39:32 PM12/8/11
to lif...@googlegroups.com
Hi!

Done

Thank you!
Reply all
Reply to author
Forward
0 new messages