GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  HTML::FORMHANDLER::MANUAL::RENDERINGCOOKBOOK (3)

.ds Aq ’

NAME

HTML::FormHandler::Manual::RenderingCookbook - rendering recipes

CONTENTS

VERSION

version 0.40065

SYNOPSIS

Collection of rendering recipes

NAME

HTML::FormHandler::Manual::Rendering::Cookbook

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...

First make your own copy of ’HTML::FormHandler::Widget::Wrapper::Table, in your own name space, and specify that name space 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] } } );



    Render a collection of checkboxes like a checkbox group

    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 html5 output which adds a ’required’ attribute.

Or use the ’html_attributes’ callback:



    <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) 2016 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.

Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 HTML::FORMHANDLER::MANUAL::RENDERINGCOOKBOOK (3) 2016-03-20

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.