| Previous · Next | |
| User | Message |
|
iadawn
|
Date: 6/8/2007 3:47 am · Subject: WebGUI::HTMLForm AUTOLOAD · Rating: -7
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 { 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
|
Date: 6/8/2007 4:05 am · Subject: Re: WebGUI::HTMLForm AUTOLOAD · Rating: 2
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
|
Date: 6/8/2007 4:29 am · Subject: Re: WebGUI::HTMLForm AUTOLOAD · Rating: -4
> 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
|
Date: 6/12/2007 9:51 am · Subject: Re: WebGUI::HTMLForm AUTOLOAD · Rating: -13
You're absolutely right. ||= is better in this case. I've changed it in 7.4.
|
| Back to Top |
Rate [ | ]
|