[Petal] var:object/method fails on autoloaded methods

Kurt Stephens kstep@pepsdesign.com
Fri, 30 Aug 2002 21:42:23 -0400


I was playing around with using Petal for form processing using CGI.pm, and
noticed that expressions such as "query/param 'FirstName'" work fine while
"query/textfield 'FirstName'" fail.  After looking through CGI.pm, I
realized that the param method is compiled when the module loads, however
the HTML generating methods are autoloaded on demand.  I was able to correct
this in the case of CGI.pm using the -compile option, however this will not
work for other packages using autoloaded methods that do not provide a means
for overriding the autoload behavior.

By the way, calling the HTML generating methods of CGI.pm from the Petal
template provides an extremely simple means to develop forms.  For example,
the ususal ratnest of loops used to populate a checkbox group can be
replaced by the simple elegant construct below.  I left in a dummy checkbox
to give the HTML designer something to look at.

<span petal:replace="query/checkbox_group 'Choices' choices '' 'true'">
<input name="Choices" type="checkbox" value="test">Test</input>
</span>


Best Regards,

Kurt Stephens
kstep@pepsdesign.com