- fix [ 1274951 ] Unable to drag rank in asset manager

- fix [ 1276449 ] 6.7.1 content invisible after edit by content manager
 - Fixed a few bugs in the new form system related to UI levels and hidden
   fields.
This commit is contained in:
JT Smith 2005-08-31 19:23:46 +00:00
parent 97161c798e
commit c687487df1
10 changed files with 208 additions and 171 deletions

View file

@ -17,6 +17,7 @@ package WebGUI::Form::Date;
use strict;
use base 'WebGUI::Form::Text';
use WebGUI::DateTime;
use WebGUI::Form::Hidden;
use WebGUI::Form::Text;
use WebGUI::International;
use WebGUI::Session;
@ -145,5 +146,21 @@ sub toHtml {
</script>';
}
#-------------------------------------------------------------------
=head2 toHtmlAsHidden ( )
Renders the form field to HTML as a hidden field rather than whatever field type it was supposed to be.
=cut
sub toHtmlAsHidden {
my $self = shift;
return WebGUI::Form::Hidden->new(
name=>$self->{name},
value=>WebGUI::DateTime::epochToSet($self->{value})
)->toHtmlAsHidden;
}
1;

View file

@ -16,6 +16,7 @@ package WebGUI::Form::DateTime;
use strict;
use base 'WebGUI::Form::Text';
use WebGUI::Form::Hidden;
use WebGUI::DateTime;
use WebGUI::International;
use WebGUI::Session;
@ -144,5 +145,21 @@ sub toHtml {
</script>';
}
#-------------------------------------------------------------------
=head2 toHtmlAsHidden ( )
Renders the form field to HTML as a hidden field rather than whatever field type it was supposed to be.
=cut
sub toHtmlAsHidden {
my $self = shift;
return WebGUI::Form::Hidden->new(
name=>$self->{name},
value=>WebGUI::DateTime::epochToSet($self->{value},1)
)->toHtmlAsHidden;
}
1;

View file

@ -0,0 +1,145 @@
package WebGUI::Form::DynamicField;
=head1 LEGAL
-------------------------------------------------------------------
WebGUI is Copyright 2001-2005 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;
use WebGUI::Session;
use WebGUI::Utility;
=head1 NAME
Package WebGUI::Form::DynamicField
=head1 DESCRIPTION
Creates the appropriate form field type given the inputs.
=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 definition ( [ additionalTerms ] )
See the super class for additional details.
=head3 additionalTerms
The following additional parameters have been added via this sub class.
=head4 fieldType
Defaults to "Text". Should be any valid field type.
=cut
sub definition {
my $class = shift;
my $definition = shift || [];
push(@{$definition}, {
fieldType=>{
defaultValue=> "Text"
},
});
return $class->SUPER::definition($definition);
}
#-------------------------------------------------------------------
=head2 getName ()
Returns the human readable name or type of this form control.
=cut
sub getName {
return WebGUI::International::get("475","WebGUI");
}
#-------------------------------------------------------------------
=head2 new ( params)
Creates the object for the appropriate field type.
=head3 params
The normal params you'd pass in to the field. Included in this list must be one element called "fieldType" which specifies what type of field to dynamically render.
=cut
sub new {
my $class = shift;
my $self = $class->SUPER::new(@_);
my $param = {};
foreach my $key (keys %{$self}) {
$param->{$key} = $self->{$key};
}
my $fieldType = ucfirst($param->{fieldType});
delete $param->{fieldType};
# Set options for fields that use a list.
if (isIn($fieldType,qw(SelectList CheckList RadioList))) {
delete $param->{size};
my %options;
tie %options, 'Tie::IxHash';
foreach (split(/\n/, $param->{possibleValues})) {
s/\s+$//; # remove trailing spaces
$options{$_} = $_;
}
if (exists $param->{options} && ref($param->{options}) eq "HASH") {
%options = (%{$param->{options}} , %options);
}
$param->{options} = \%options;
}
# Convert value to list for selectList / checkList
if (isIn($fieldType,qw(SelectList CheckList)) && ref $param->{value} ne "ARRAY") {
my @defaultValues;
foreach (split(/\n/, $param->{value})) {
s/\s+$//; # remove trailing spaces
push(@defaultValues, $_);
}
$param->{value} = \@defaultValues;
}
# Return the appropriate field object.
if ($fieldType eq "") {
WebGUI::ErrorHandler::warn("Something is trying to create a dynamic field called ".$param->{name}.", but didn't pass in a field type.");
$fieldType = "Text";
}
no strict 'refs';
my $cmd = "WebGUI::Form::".$fieldType;
my $load = "use ".$cmd;
eval ($load);
if ($@) {
WebGUI::ErrorHandler::error("Couldn't compile form control: ".$fieldType.". Root cause: ".$@);
return undef;
}
return $cmd->new($param);
}
1;

View file

@ -110,7 +110,7 @@ sub toHtmlAsHidden {
my $self = shift;
my $output;
foreach my $key (keys %{$self->{options}}) {
foreach my $item (@{$self->{values}}) {
foreach my $item (@{$self->{value}}) {
if ($item eq $key) {
$output .= WebGUI::Form::Hidden->(
name=>$self->{name},

View file

@ -149,13 +149,13 @@ sub toHtmlAsHidden {
my $self = shift;
my ($interval, $units) = WebGUI::DateTime::secondsToInterval($self->{value});
return WebGUI::Form::Hidden->new(
"name"=>$self->{name}.'_interval',
"value"=>$interval
name=>$self->{name}.'_interval',
value=>$interval
)->toHtmlAsHidden
.WebGUI::Form::Hidden->new(
"name"=>$self->{name}.'_units',
"value"=>$units
)->toHtmmlAsHidden;
name=>$self->{name}.'_units',
value=>$units
)->toHtmlAsHidden;
}
1;