Click here to register.
      
Sprechen Sie WebGUI? Parlez vous WebGUI? Se habla WebGUI? Spreekt u WebGUI?

Do you speak WebGUI? Please help us translate WebGUI into your language.



     Discuss > WebGUI Dev

WebGUI::HTMLForm AUTOLOAD

User iadawn
Date 6/8/2007 3:47 am
Views 1590
Rating -7    Rate [
|
]
Previous · Next
User Message
iadawn

Lo,

I was looking at doing something funky with an Wobject form and needed to tag the table row so that I could attach some Javascript to them. So I shuffled around the code and found WebGUI::Form::Control::toHtmlwithWrapper  which constructs the table row. Within the definition of this object are a couple of handy little attributes, one in particular: rowClass. The comment didn't clear up my confusion about what this was but the code was quite clear:

sub displayFormWithWrapper {
    my $self = shift;
    if ($self->passUiLevelCheck) {
        my ($fieldClass, $rowClass, $labelClass, $hoverHelp, $subtext)  = $self->prepareWrapper;
        return '<tr'.$rowClass.'>
                <td'.$labelClass.$hoverHelp.' valign="top" style="width: 25%;">'.$self->get("label").'</td>
                <td valign="top"'.$fieldClass.' style="width: 75%;">'.$self->displayForm().$subtext."</td>
            </tr>\n";

Grand, exactly what I need without having to change any core modules. So I change my Wobject to include rowClass where appropriate, restart and reload the page. No rowClass in the row. Huh?

So I firkle around a bit more and bump into WebGUI::HTMLForm::AUTOLOAD which has the line:

     $params{rowClass} = $self->{_class};

before it calls  the toHtmlwithWrapper.

Could anyone explain to me why this line is here? _class can be set  using WebGUI::HTMLForm::trClass.

Would the line not be better presented as:

    $params{rowClass} ||= $self->{_class};

?

Cheers

Kevin
 



Back to Top
Rate [
|
]
 
 
martink
You should set the rowClass with the trClass method of the HTMLForm. Ie:

my $f = WebGUI::HTMLForm->new($session);
$f->integer(
   ...
);
$f->trClass('myRowClassName');
$->text(
   ...
);
$f->trClass('');
$f->selectBox(
   ...
);

This will put the text formelement in a row with class="myRowClassname".
The integer and selecBox will be in rows without class.

Why you cannot set the rowClass through the parameters of a form element
I do not know. It seems to be a bug, or at least a unnecessary
restriction to me.

Martin

kevin@theconfused.co.uk wrote:
> iadawn wrote:
>
> Lo,
>
> I was looking at doing something funky with an Wobject form and needed
> to tag the table row so that I could attach some Javascript to them.
> So I shuffled around the code and found
> WebGUI::Form::Control::toHtmlwithWrapper  which constructs the table
> row. Within the definition of this object are a couple of handy little
> attributes, one in particular: rowClass. The comment didn't clear up
> my confusion about what this was but the code was quite clear:
>
> sub displayFormWithWrapper {
>     my $self = shift;
>     if ($self->passUiLevelCheck) {
>         my ($fieldClass, $rowClass, $labelClass, $hoverHelp,
> $subtext)  = $self->prepareWrapper;
>         return '
>                  style="width: 25%;">'.$self->get("label").'
>                 '.$self->displayForm().$subtext."
>             \n";
>
> Grand, exactly what I need without having to change any core modules.
> So I change my Wobject to include rowClass where appropriate, restart
> and reload the page. No rowClass in the row. Huh?
>
> So I firkle around a bit more and bump into WebGUI::HTMLForm::AUTOLOAD
> which has the line:
>
>      $params{rowClass} = $self->{_class};
>
> before it calls  the toHtmlwithWrapper.
>
> Could anyone explain to me why this line is here? _class can be set  
> using WebGUI::HTMLForm::trClass.
>
> Would the line not be ! better presented as:
>
>     $params{rowClass} ||= $s elf->{_class};
>
> ?
>
> Cheers
>
> Kevin
>  
>
>
>
> http://www.plainblack.com/webgui/dev/discuss/webguihtmlform-autoload
>
> Unsubscribe
>
>
> ------------------------------------------------------------------------
>
>
>
>  



Back to Top
Rate [
|
]
 
 
iadawn

> You should set the rowClass with the trClass method of the HTMLForm. Ie:

The only issue with that is that you cannot do this if you are using auto generated forms (at least I think you can't).

I have changed WebGUI::HTMLForm in the way I have indicated to address this issue. No biggie to do that.

Cheers

Kevin



Back to Top
Rate [
|
]
 
 
JT
You're absolutely right. ||= is better in this case. I've changed it in 7.4.

Back to Top
Rate [
|
]
 
 
     Discuss > WebGUI Dev



Recent Discussions Color Key

Design:

Development:

Et Cetera:

Install/Upgrade:  

Smoketest:

Template Group:


Re: Site paid for by advertizing by Klaus - Fri @ 02:27am

Smoke Test for WebGUI (Stable) (2008-11-21) by botaction - Fri @ 12:37am

Re: Site paid for by advertizing by pwrightson - Thu @ 10:59am

Re: Site paid for by advertizing by JT - Thu @ 08:58am

Re: Regelmäßiger Termin für Usertreffen in der Rhein-Neckar-Region by Klaus - Thu @ 06:11am

Smoke Test for WebGUI (Stable) (2008-11-20) by botaction - Thu @ 12:00am

Smoke Test for SVN (2008-11-20) by botaction - Thu @ 12:00am

Re: Improving page layouts by fdillon - Wed @ 08:38pm

Re: Improving page layouts by knowmad - Wed @ 08:25pm

Re: Site paid for by advertizing by knowmad - Wed @ 08:07pm

Re: SSL Configuration? by knowmad - Wed @ 07:51pm

Re: The Death of the Collaboration System by preaction - Wed @ 07:39pm