Skip to content

Commit

Permalink
updated role docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Devin Austin committed Jan 3, 2012
1 parent f7631ea commit 145e424
Show file tree
Hide file tree
Showing 2 changed files with 116 additions and 0 deletions.
52 changes: 52 additions & 0 deletions lib/Form/Sensible/Reflector/DBIC/Role/FieldClassOptions.pm
Expand Up @@ -2,6 +2,58 @@ package Form::Sensible::Reflector::DBIC::Role::FieldClassOptions;
use Moose::Role;
use namespace::autoclean;

=head1 NAME
Form::Sensible::Reflector::DBIC::Role::FieldClassOptions - Sane defaults for field classes.
=cut


=head1 $self->field_class_options
Hashref of default field class options.
Current incarnation:
'Number' => {
'validation' => {
'integer_only' => 'integer_only',
'upper_bound' => 'upper_bound',
'lower_bound' => 'lower_bound',
'step' => 'step',
},
},
'Toggle' => {
'render_hints' => {
'on_value' => 'on_value',
'on_label' => 'on_label',
'off_value' => 'off_value',
'off_label' => 'off_label',
},
},
'Text' => {
'validation' => {
'size' => 'maximum_length',
'minimum_length' => 'minimum_length',
'maximum_length' => 'maximum_length',
'should_truncate' => 'should_truncate',
},
},
'LongText' => {
'validation' => {
'size' => 'maximum_length',
'minimum_length' => 'minimum_length',
'maximum_length' => 'maximum_length',
'should_truncate' => 'should_truncate',
},
},
'FileSelector' => { 'validation' => { 'size' => 'maximum_size', }, },
'Select' =>
{ 'validation' => { 'options_delegate' => 'options_delegate', }, },
=cut

has 'field_class_options' => (
is => 'rw',
isa => 'HashRef',
Expand Down
64 changes: 64 additions & 0 deletions lib/Form/Sensible/Reflector/DBIC/Role/FieldTypeMap.pm
Expand Up @@ -2,6 +2,61 @@ package Form::Sensible::Reflector::DBIC::Role::FieldTypeMap;
use Moose::Role;
use namespace::autoclean;

=head1 NAME
Form::Sensible::Reflector::DBIC::Role::FieldTypeMap - Map generic SQL data types to L<Form::Sensible> field types.
=cut

=head1 $self->field_type_map
Define a hashref of field->types.
Current incarnation is as follows:
varchar => { defaults => { field_class => 'Text', }, },
text => { defaults => { field_class => 'LongText', }, },
blob => { defaults => { field_class => 'FileSelector' }, },
datetime => { defaults => { field_class => 'Text', }, },
enum => { defaults => { field_class => 'Select', }, },
int => {
defaults => {
field_class => 'Number',
integer_only => 1,
},
},
integer => {
defaults => {
field_class => 'Number',
integer_only => 1,
},
},
bigint => {
defaults => {
field_class => 'Number',
integer_only => 1,
},
},
bool => {
defaults => {
field_class => 'Toggle',
on_value => 1,
on_label => 'yes',
off_value => 0,
off_label => 'no'
},
},
decimal => {
defaults => {
field_class => 'Number',
integer_only => 0,
},
},
};
=cut

has field_type_map => (
is => 'rw',
isa => 'HashRef',
Expand Down Expand Up @@ -52,4 +107,13 @@ sub _build_field_type_map {
};
};


=head1 AUTHOR
Devin Austin L<mailto:devin.austin@ionzero.com>
Andre Walker L<http://andrewalker.net>
=cut

1;

0 comments on commit 145e424

Please sign in to comment.