Skip to content

Commit

Permalink
Item11806 : add more flexibility for manipulating stored key-values a…
Browse files Browse the repository at this point in the history
…nd rendering (just) the value

git-svn-id: http://svn.foswiki.org/trunk@14761 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
ArthurClemens authored and ArthurClemens committed May 7, 2012
1 parent 633f23b commit 80f61b9
Showing 1 changed file with 44 additions and 9 deletions.
53 changes: 44 additions & 9 deletions core/lib/Foswiki/Form/FieldDefinition.pm
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ sub renderHidden {

=begin TML
---++ populateMetaDataFromQuery( $query, $meta, $old ) -> ($bValid, $bPresent)
---++ ObjectMethod populateMetaDataFromQuery( $query, $meta, $old ) -> ($bValid, $bPresent)
Given a CGI =$query=, a =$meta= object, and an array of =$old= field entries,
then populate the $meta with a row for this field definition, taking the
Expand Down Expand Up @@ -300,12 +300,15 @@ sub populateMetaFromQueryData {
if ( $this->{definingTopic} ) {
$title = '[[' . $this->{definingTopic} . '][' . $title . ']]';
}
$def = {
name => $this->{name},
title => $title,
value => $value,
attributes => $this->{attributes},
};
$def = $this->createMetaKeyValues(
$query, $meta,
{
name => $this->{name},
title => $title,
value => $value,
attributes => $this->{attributes},
}
);
}
elsif ($preDef) {
$def = $preDef;
Expand All @@ -321,6 +324,22 @@ sub populateMetaFromQueryData {

=begin TML
---++ ObjectMethod createMetaKeyValues( $query, $meta, $keyvalues ) -> $keyvalues
Create meta key/value pairs hash, to be overridden by subclasses.
Default implementation passes all inputs unchanged.
=cut

sub createMetaKeyValues {

#my ( $this, $query, $meta, $keyvalues ) = @_;

return $_[3];
}

=begin TML
---++ ObjectMethod renderForDisplay($format, $attrs) -> $html
Render the field for display, under the control of $attrs.
Expand All @@ -347,7 +366,7 @@ sub renderForDisplay {
$value = Foswiki::Render::protectFormFieldValue( $value, $attrs );

$format =~ s/\$title/$this->{title}/g;
$format =~ s/\$value/$value/g;
$format =~ s/\$value/$this->renderValueForDisplay($value)/ge;
$format =~ s/\$name/$this->{name}/g;
$format =~ s/\$attributes/$this->{attributes}/g;
$format =~ s/\$type/$this->{type}/g;
Expand All @@ -358,6 +377,22 @@ sub renderForDisplay {
return $format;
}

=begin TML
---++ ObjectMethod renderValueForDisplay($value) -> $html
Render the field value for display, to be overridden by subclasses.
Default implementation passes the value unchanged.
=cut

sub renderValueForDisplay {

# my ( $this, $value ) = @_;

return $_[1];
}

# Debug
sub stringify {
my $this = shift;
Expand All @@ -373,7 +408,7 @@ sub stringify {
__END__
Foswiki - The Free and Open Source Wiki, http://foswiki.org/
Copyright (C) 2008-2010 Foswiki Contributors. Foswiki Contributors
Copyright (C) 2008-2012 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 80f61b9

Please sign in to comment.