--- trunk/lib/Frey/Action.pm 2008/11/20 14:39:43 480
+++ trunk/lib/Frey/Action.pm 2008/11/24 22:08:10 504
@@ -103,6 +103,17 @@
my $form;
+ sub select_values {
+ my ( $name, $attr_type, $values ) = @_;
+ my $options = join("\n",
+ map {
+ my $v = ref($_) eq 'HASH' ? $_->{$name} : $_;
+ qq|| if $v;
+ } @$values
+ );
+ qq|| if $options;
+ }
+
foreach my $name ( grep { ! $class->meta->get_attribute($_)->is_lazy } $self->attributes ) {
my $attr_type = '';
my $type = $name =~ m/^pass/ ? 'password' : 'text';
@@ -110,32 +121,22 @@
my $value = '';
my $label_title = '';
my $value_html = '';
+
+ my $attr = $class->meta->get_attribute( $name );
+ $attr_type = $attr->type_constraint->name if $attr->has_type_constraint;
+
if ( ref($config_params) eq 'HASH' ) {
$value = $config_params->{$name};
} elsif ( ref($config_params) eq 'ARRAY' ) {
- $value_html = qq||;
+ $value_html = select_values( $name, $attr_type, $config_params );
$default->{$name} = $config_params->[0]->{$name};
- } elsif ( my $attr = $class->meta->get_attribute( $name ) ) {
- if ( $attr->has_type_constraint ) {
- $attr_type = $attr->type_constraint->name;
- if ( $attr->type_constraint->can('values') ) {
- $value_html = qq||;
- } elsif ( $attr_type !~ m{^(Str|Int)$} ) {
- $value_html = qq||;
- }
- }
- $value = $attr->default( $name ) if ! $value && $attr->has_default;
- $label_title = qq| title="| . $attr->documentation . qq|"| if $attr->has_documentation;
- } else {
- warn "wired attribute $name";
+ } elsif ( $attr->has_type_constraint && $attr->type_constraint->can('values') ) {
+ $value_html = select_values( $name, $attr_type, $attr->type_constraint->values );
+ } elsif ( $attr_type !~ m{^(Str|Int)$} ) {
+ $value_html = qq||;
}
+ $value = $attr->default( $name ) if ! $value && $attr->has_default;
+ $label_title = qq| title="| . $attr->documentation . qq|"| if $attr->has_documentation;
$default->{$name} = $value unless defined $default->{$name};