Skip to content

Commit

Permalink
Item9106: Add dynamiclabel type
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.foswiki.org/trunk/NestedFormsPlugin@7650 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
PaulHarvey authored and PaulHarvey committed Jun 6, 2010
0 parents commit 490387a
Showing 1 changed file with 66 additions and 0 deletions.
66 changes: 66 additions & 0 deletions lib/Foswiki/Form/Dynamiclabel.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# See bottom of file for license and copyright information
package Foswiki::Form::Dynamiclabel;

use strict;
use warnings;
use Assert;

use Foswiki::Form::FieldDefinition ();
our @ISA = ('Foswiki::Form::FieldDefinition');

sub isEditable {
return 0;
}

sub renderForDisplay {
my ( $this, $format, $value, $attrs ) = @_;

ASSERT( !$value ) if DEBUG;
my $_format =
$this->SUPER::renderForDisplay( $format, $this->SUPER::getDefaultValue(),
$attrs );

return $_format;
}

sub renderForEdit {
my ( $this, $topicObject, $value ) = @_;

ASSERT( !$value ) if DEBUG;
my $renderedValue =
$topicObject->renderTML(
$topicObject->expandMacros( $this->SUPER::getDefaultValue() ) );
return ( '',
CGI::hidden( -name => $this->{name}, -value => '' )
. CGI::div( {}, $renderedValue ) );
}

1;
__END__
Foswiki - The Free and Open Source Wiki, http://foswiki.org/
Copyright (C) 2010 Paul.W.Harvey@csiro.au Centre for Plant Biodiversity Research
http://www.trin.org.au - http://www.anbg.gov.au/cpbr/ - http://www.csiro.au/pi
Additional copyrights apply to some or all of the code in this
file as follows:
Copyright (C) 2008-2010 Foswiki Contributors. Foswiki Contributors
are listed in the AUTHORS file in the root of this distribution.
NOTE: Please extend that file, not this notice.
Copyright (C) 2001-2007 TWiki Contributors. All Rights Reserved.
TWiki Contributors are listed in the AUTHORS file in the root
of this distribution. NOTE: Please extend that file, not this notice.
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. For
more details read LICENSE in the root of this distribution.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
As per the GPL, removal of this notice is prohibited.

0 comments on commit 490387a

Please sign in to comment.