add wg-form-TYPE class to all form control wrappers
This commit is contained in:
parent
0c25620867
commit
0168cb16a4
2 changed files with 29 additions and 2 deletions
|
|
@ -16,6 +16,7 @@ package WebGUI::Form::Control;
|
|||
|
||||
use strict;
|
||||
use WebGUI::International;
|
||||
use Scalar::Util qw( blessed );
|
||||
|
||||
=head1 NAME
|
||||
|
||||
|
|
@ -425,6 +426,23 @@ sub getDefaultValue {
|
|||
return $self->get("defaultValue");
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 getPackageClassName ( )
|
||||
|
||||
Get the class name for this package. Defaults to 'wg-form-typeCamelCase' (so, a
|
||||
WebGUI::Form::Button would have a class of 'wg-form-button' and a
|
||||
WebGUI::Form::SelectBox would have a class of 'wg-form-selectBox')
|
||||
|
||||
=cut
|
||||
|
||||
sub getPackageClassName {
|
||||
my ( $self ) = @_;
|
||||
my $package = blessed $self;
|
||||
$package =~ s/WebGUI::Form:://;
|
||||
return 'wg-form-' . lcfirst $package;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getValueAsHtml ( )
|
||||
|
|
@ -591,8 +609,8 @@ Common code for preparing wrappers for *WithWrapper
|
|||
|
||||
sub prepareWrapper {
|
||||
my $self = shift;
|
||||
my $rowClass = $self->get("rowClass");
|
||||
$rowClass = qq| class="$rowClass" | if($self->get("rowClass"));
|
||||
my $rowClass = join " ", $self->get("rowClass"), $self->getPackageClassName;
|
||||
$rowClass = qq| class="$rowClass" |;
|
||||
my $fieldClass = $self->get("fieldClass");
|
||||
$fieldClass = qq| class="$fieldClass" | if($self->get("fieldClass"));
|
||||
my $subtext = $self->get("subtext");
|
||||
|
|
|
|||
|
|
@ -40,6 +40,15 @@ sub t_00_method_check : Test(1) {
|
|||
can_ok $form, qw/get set headTags toHtml prepareWrapper toHtmlAsHidden toHtmlWithWrapper isInRequest isDynamicCompatible getName/;
|
||||
}
|
||||
|
||||
sub t_01_getPackageClassName : Test(1) {
|
||||
my $test = shift;
|
||||
my $session = $test->session;
|
||||
|
||||
my $form = $test->class->new($session);
|
||||
my $package = $test->class;
|
||||
$package =~ s/WebGUI::Form:://;
|
||||
is $form->getPackageClassName, 'wg-form-' . lcfirst $package;
|
||||
}
|
||||
|
||||
sub t_01_get_set : Test(3) {
|
||||
my $test = shift;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue