Skip to content

Commit

Permalink
Item11666: fix default of radios and selects in forms to be as per docco
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.foswiki.org/trunk@14449 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
CrawfordCurrie authored and CrawfordCurrie committed Mar 23, 2012
1 parent 82c4b62 commit b7c67e3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions core/lib/Foswiki/Form.pm
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,7 @@ sub renderForEdit {
my $extra = ''; # extras on col 0

unless ( defined($value) ) {

my $dv = $fieldDef->getDefaultValue($value);
if ( defined($dv) ) {
$dv = $topicObject->expandMacros($dv);
Expand Down
6 changes: 6 additions & 0 deletions core/lib/Foswiki/Form/Radio.pm
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ sub finish {
undef $this->{valueMap};
}

# From System.DataForms, "The first item in the list for a select or
# radio type is the default item."
sub getDefaultValue {
return shift->getOptions()->[0];
}

sub getOptions {
my $this = shift;

Expand Down
7 changes: 3 additions & 4 deletions core/lib/Foswiki/Form/Select.pm
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,13 @@ sub new {
=begin TML
---++ getDefaultValue() -> $value
The default for a select is always the empty string, as there is no way in
Foswiki form definitions to indicate selected values. This defers the decision
on a value to the browser.
From System.DataForms, "The first item in the list for a select or
radio type is the default item."
=cut

sub getDefaultValue {
return '';
return shift->getOptions()->[0];
}

sub getOptions {
Expand Down

0 comments on commit b7c67e3

Please sign in to comment.