简体   繁体   中英

How to render individual fields with HTML::FormHandler

I am creating a form and am using HTML::FormHandler. I have a select field similar to the following:

has_field color => (
type => 'Select',
default => 'green',
);

sub options_color {
    return [[ qw(red green blue)]];
}

In my template if I use the following line to render the form this select field renders properly as a drop down list populated with the options I set in the options_color method.

[% form.render %]

However, I would like to render fields individually. I believe I am using the method render_field correctly to render just the color field, but the following line produces nothing in my browser.

[% form.render_field('color') %]

I believe my code matches the documentation, but I am not seeing the behavior that the documentation for HTML::FormHandler describes. Any ideas would be very helpful. Thanks!

Solved. Despite the render_field method being documented as the way to render an individual field, I was able to render the color field using the following line:

[% form.field('color').render %]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM