Form::Factory::Control::Role::Labeled - labeled controls


Form-Factory documentation Contained in the Form-Factory distribution.

Index


Code Index:

NAME

Top

Form::Factory::Control::Role::Labeled - labeled controls

VERSION

Top

version 0.020

DESCRIPTION

Top

Implemented by any control with a label.

ATTRIBUTES

Top

label

The label. By default it is created from the control's name.

AUTHOR

Top

Andrew Sterling Hanenkamp <hanenkamp@cpan.org>

COPYRIGHT AND LICENSE

Top


Form-Factory documentation Contained in the Form-Factory distribution.
package Form::Factory::Control::Role::Labeled;
BEGIN {
  $Form::Factory::Control::Role::Labeled::VERSION = '0.020';
}
use Moose::Role;

has label => (
    is        => 'ro',
    isa       => 'Str',
    required  => 1,
    builder   => '_build_label',
);

sub _build_label {
    my $self = shift;
    my $label = $self->name;
    $label =~ s/_/ /g;
    $label =~ s/\b(\w)/\U$1\E/g;
    return $label;
}

1;