On Dec 22, 2009, at 5:12 PM, Justin Wyllie wrote:
> Hi Chris
>
> I think this is browser behaviour: if the checkbox is unticked it
> won't send
> anything at all.
>
> And according to the Mason book if you declare an argument in an
> %args block
> without a default value then that means it is required. So, if the
> user does
> not check the box the checkbox key/value is not sent at all and you
> get your
> error.
>
> Maybe if you define a default for it:
>
> <%args>
> $m => 'x'
> </%args>
>
> Then you can tell: if 'v' it was checked. If 'x' not checked (and no
> error)
>
> regards
>
> Justin
> E. [email protected]
Be careful with your use of $m as your variable as $m is typically
defined as a reference to the Mason request object. Confusing things
can happen if you use $m for something other than the Mason request
object. I've been there ;-)
The way I would tend to do this is only slightly different than what
is suggested above (assume that the checkbox field name is "cb"):
<%args>
$cb => undef
</%args>
if (defined($cb)) { # true if the checkbox is checked. }
if (!defined($cb)) { # true if the checkbox is not checked. }
Steve
--
---------------------------------------------------------------
Steven Saner
[email protected]
------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev
_______________________________________________
Mason-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mason-users