HTML::...okbook(3pm)
π NAME π
okay bestie, welcome to HTML::FormHandler::Manual::RenderingCookbook β the page filed as HTML::...okbook(3pm). It's literally rendering recipes, and we are gonna get into it. π«Ά
β¨ VERSION β¨
version 0.40068 β yes, that's the version, bestie. π
π SYNOPSIS π
Collection of rendering recipes. That's the whole synopsis, and she ate. β¨
πΈ NAME πΈ (yes, again β she's iconic like that)
HTML::FormHandler::Manual::Rendering::Cookbook.
Not me noticing there are two NAME sections β we're keeping them both because details are sacred. π
π Recipes π
π Custom renderer, custom attributes π
You want to be able to specify the attributes that are rendered in the td tag of the table renderer... yes, that vibe. π
First, make your own copy of HTML::FormHandler::Widget::Wrapper::Table in your own namespace, and specify that namespace in the widget_name_space for the form.
Change this line in the Table wrapper:
$output .= '<td>' . $self->do_render_label($result) . '</td>';
to this:
my $td_attr = process_attrs($self->get_tag('td_attr') || {} );
$output .= "<td$td_attr>" . $self->do_render_label($result) . '</td>';
Now you can specify the attributes for the td tag on a field:
has_field 'foo' => ( tags => { td_attr => { class => ['emph', 'label'] } } );
Slay. That's the recipe. π
π¦ Render a collection of checkboxes like a checkbox group π¦
This heading is here, and the original doesn't add extra details under it. Keep it moving, bestie. π
π Add a 'required' class to labels π
Create a custom widget wrapper:
package MyApp::Form::Widget::Wrapper::CustomLabel;
use Moose::Role;
with 'HTML::FormHandler::Widget::Wrapper::Simple';
sub render_label {
my ($self) = @_;
return '<label class="label' . ($self->required ?
' required' : '') . '" for="' . $self->id . '">' .
$self->html_filter($self->loc_label) . ':
</label>';
}
- Or enable
html5output which adds arequiredattribute. - Or use the
html_attributescallback:
<in a form>
sub html_attributes {
my ( $self, $field, $type, $attr ) = @_;
push @{$attr->{class}}, 'required'
if ( $type eq 'label' && $field->required );
}
π AUTHOR π
FormHandler Contributors β see HTML::FormHandler. π«Ά
π COPYRIGHT AND LICENSE π
This software is copyright (c) 2017 by Gerda Shank.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
This page is HTML::...okbook(3pm), built with perl v5.34.0 and dated 2022-03-25. Mwah, bestie β go render something iconic. πβ¨
π¦ where this page comes from
- debian bookworm: libhtml-formhandler-perl 0.40068-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libhtml-formhandler-perl 0.40068-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libhtml-formhandler-perl 0.40068-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libhtml-formhandler-perl 0.40068-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms