yesno — display a yes/no option
The yesno
widget creates a simple "Yes or No" option.
The actual widget titles, "Yes
" and
"No
", are locale-aware so adding their
translated versions to the locale database will be enough to
have them adjusted to visitors' language settings.
A negative answer will return a blank (false) value to the application.
A positive answer will return value 1
(true) to the application.
Example: 'Yes or No' widget, rendered as a "radio" button
[display name=example type=yesno variant=radio]
Example: 'Yes or No' widget, created in an alternative way
[display]
tag:
[display name=example type=select passed="=No,1=Yes"]
The widget is created by Interchange's Vend::Form::yesno
function. Passing attribute type="yesno radio"
to it is
equivalent to passing attributes type=yesno variant=radio
.
However, only method type="yesno radio"
is available if the
widget is invoked through the [widget]
tag and ITL.
Interchange 5.9.0:
Source: code/Widget/yesno.widget
Lines: 12
# Copyright 2005-2007 Interchange Development Group and others # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. # # $Id: yesno.widget,v 1.3 2007-03-30 23:40:58 pajamian Exp $ CodeDef yesno Widget 1 CodeDef yesno Description Yes/No (Yes=1) CodeDef yesno MapRoutine Vend::Form::yesno
Source: lib/Vend/Form.pm
Lines: 909
sub yesno { my $opt = shift; $opt->{value} = is_yes($opt->{value}); my $yes = defined $opt->{yes_value} ? $opt->{yes_value} : 1; my $no = defined $opt->{no_value} ? $opt->{no_value} : ''; my $yes_title = defined $opt->{yes_title} ? $opt->{yes_title} : errmsg('Yes'); my $no_title = defined $opt->{no_title} ? $opt->{no_title} : errmsg('No'); my @opts; my $routine = $opt->{subwidget} || \&dropdown; if($opt->{variant} eq 'checkbox') { @opts = [$yes, ' ']; } else { @opts = ( [$no, $no_title], [$yes, $yes_title], ); } return $routine->($opt, \@opts); }