Skip to content

Commit

Permalink
Item10874: "Add form" button saved fully-qualified web.topic name
Browse files Browse the repository at this point in the history
Don't save fully-qualified web.topic name unless that's actually what is in
WEBFORMS preference

git-svn-id: http://svn.foswiki.org/branches/Release01x01@11911 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
PaulHarvey authored and PaulHarvey committed Jun 14, 2011
1 parent 1e4399e commit 81f9bed
Showing 1 changed file with 44 additions and 20 deletions.
64 changes: 44 additions & 20 deletions core/lib/Foswiki/UI/ChangeForm.pm
Expand Up @@ -35,47 +35,50 @@ sub generate {
my $q = $session->{request};

my $formName = $q->param('formtemplate') || '';
my $fqFormName;
unless ($formName) {
if ( not defined $topicObject->getLoadedRev() ) {
$topicObject->load();
}
my $form = $topicObject->get('FORM');
$formName = $form->{name} if $form;
}
$formName = 'none' if ( !$formName );
if ( not $formName ) {
$formName = 'none';
$fqFormName = $formName;
}
else {
$fqFormName = _normalizeName( $topicObject, $formName );
}

my @forms = Foswiki::Form::getAvailableForms($topicObject);
unshift( @forms, 'none' );
my @webforms = Foswiki::Form::getAvailableForms($topicObject);
unshift( @webforms, 'none' );

my $formList = '';
my $formElemCount = 0;
foreach my $form (@forms) {
foreach my $webform (@webforms) {
my $fqwebform = _normalizeName( $topicObject, $webform );

$formElemCount++;
$formList .= CGI::br() if ($formList);
if ( $form ne 'none' ) {
$form = join(
'.',
Foswiki::Func::normalizeWebTopicName(
$topicObject->web(), $form
)
);
}
my $formElemId = 'formtemplateelem' . $formElemCount;
my $props = {
type => 'radio',
name => 'formtemplate',
id => $formElemId,
value => $form
value => $webform
};
$props->{checked} = 'checked' if $form eq $formName;
$props->{checked} = 'checked' if $fqwebform eq $fqFormName;
$formList .= CGI::input($props);
my ( $formWeb, $formTopic ) =
$session->normalizeWebTopicName( $topicObject->web, $form );
my $formLabelContent = ' '
. (
$session->topicExists( $formWeb, $formTopic )
? '[[' . $formWeb . '.' . $formTopic . '][' . $form . ']]'
: $form
Foswiki::Func::topicExists(
Foswiki::Func::normalizeWebTopicName(
$topicObject->web(), $fqwebform
)
)
? "[[$fqwebform][$webform]]"
: $webform
);
$formList .= CGI::label( { for => $formElemId }, $formLabelContent );
}
Expand All @@ -100,11 +103,32 @@ sub generate {

return $page;
}

sub _normalizeName {
my ( $topicObject, $name ) = @_;

if ($name) {
if ( $name ne 'none' ) {
$name = join(
'.',
Foswiki::Func::normalizeWebTopicName(
$topicObject->web(), $name
)
);
}
}
else {
$name = 'none';
}

return $name;
}

1;
__END__
Foswiki - The Free and Open Source Wiki, http://foswiki.org/
Copyright (C) 2008-2010 Foswiki Contributors. Foswiki Contributors
Copyright (C) 2008-2011 Foswiki Contributors. Foswiki Contributors
are listed in the AUTHORS file in the root of this distribution.
NOTE: Please extend that file, not this notice.
Expand Down

0 comments on commit 81f9bed

Please sign in to comment.