webgui/lib/WebGUI/Form/JsonBlob.pm
2011-12-28 11:30:38 -08:00

138 lines
3.1 KiB
Perl

package WebGUI::Form::JsonBlob;
=head1 LEGAL
-------------------------------------------------------------------
WebGUI is Copyright 2001-2012 Plain Black Corporation.
-------------------------------------------------------------------
Please read the legal notices (docs/legal.txt) and the license
(docs/license.txt) that came with this distribution before using
this software.
-------------------------------------------------------------------
http://www.plainblack.com info@plainblack.com
-------------------------------------------------------------------
=cut
use strict;
use base 'WebGUI::Form::Control';
use WebGUI::International;
=head1 NAME
Package WebGUI::Form::JsonBlob
=head1 DESCRIPTION
Creates a JSON blob field. There is no visual interface for this form control, nor does it output a hidden field. It's meant to be used as a backend element only.
=head1 SEE ALSO
This is a subclass of WebGUI::Form::Control.
=head1 METHODS
The following methods are specifically available from this class. Check the superclass for additional methods.
=cut
#-------------------------------------------------------------------
=head2 generateIdParameter ( )
A class method that returns a value to be used as the autogenerated ID for this field instance. Returns undef because this field type can have more than one with the same name, therefore autogenerated ID's aren't terribly useful.
=cut
sub generateIdParameter {
return undef;
}
#-------------------------------------------------------------------
=head2 getDatabaseFieldType ( )
Returns "mediumtext".
=cut
sub getDatabaseFieldType {
return "mediumtext";
}
#-------------------------------------------------------------------
=head2 getName ( session )
Returns the human readable name of this control.
=cut
sub getName {
my ($self, $session) = @_;
return WebGUI::International->new($session, 'WebGUI')->get('JSON Blob');
}
#-------------------------------------------------------------------
=head2 getValueAsScalar ()
=cut
sub getValueAsScalar {
my $self = shift;
return JSON->new->canonical->encode($self->getValue);
}
#-------------------------------------------------------------------
=head2 isDynamicCompatible ( )
A class method that returns a boolean indicating whether this control is compatible with the DynamicField control.
=cut
sub isDynamicCompatible {
return 0;
}
#-------------------------------------------------------------------
=head2 toHtml ( )
A synonym for toHtmlAsHidden.
=cut
sub toHtml {
return undef;
}
#-------------------------------------------------------------------
=head2 toHtmlAsHidden ( )
Renders an input tag of type hidden.
=cut
sub toHtmlAsHidden {
return undef;
}
#-------------------------------------------------------------------
=head2 toHtmlWithWrapper ( )
Renders the form field to HTML as a table row. The row is not displayed because there is nothing to display, but it may not be left away because <input> may not be a child of <table> according to the XHTML standard.
=cut
sub toHtmlWithWrapper {
return undef;
}
1;