Checkbox not readable by wf:q/1
Reported by Rusty Klophaus | April 28th, 2010 @ 07:54 AM | in 2.0.1
From Fabian Król on the newsgroup:
I have simple code:
content() ->
[
#flash {},
#checkbox {id=chb1, checked=true},
#checkbox {id=chb2},
#button { postback=accept }
].
event(accept) ->
Chb1 = wf:q(chb1),
Chb2 = wf:q(chb2),
wf:flash(wf:f("~s ~s", [Chb1, Chb2])).
The behavior i would expect is to get information about
checked/not
checked but i always receive value "on". It doesn't say anything
about
the state of checkbox.
Of course i can remember the state in other place and react
with
postback in checkbox object but it seems to by ugly ;)
Comments and changes to this ticket
-
Jesse Gumm May 8th, 2010 @ 07:53 PM
I've posted a fix for this, as well as added support for the "value" attribute on the checkbox field.
http://github.com/choptastic/nitrogen/commit/dce295e82d917310b2fde5...
Assuming the following checkboxes
[ #checkbox{id=fruit,value="apple",text="Apple"}, #checkbox{id=fruit,value="orange",text="Orange",checked=true}, #checkbox{id=fruit,value="banana",text="Banana",checked=true} ].
wf:qs(fruit) would yield ["orange","banana"]
This, to me, seems the appropriate way to handle checkboxes to stay consistent with HTML form submission.
-
Rusty Klophaus June 14th, 2010 @ 06:50 PM
- State changed from new to resolved
Merge changes from Jesse Gumm.
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
Nitrogen Web Framework for Erlang