--- trunk/lib/Frey/Action.pm 2008/11/28 17:18:56 595 +++ trunk/lib/Frey/Action.pm 2008/11/30 16:22:45 645 @@ -114,18 +114,35 @@ qq|| if $options; } - foreach my $name ( grep { ! $class->meta->get_attribute($_)->is_lazy } $self->attributes ) { + foreach my $checkbox ( split(/\s+/, $default->{'frey-checkboxes'} ) ) { + next if defined $default->{ $checkbox }; + + $default->{ $checkbox } = 0; + $self->params->{ $checkbox } = 0; + warn "# checkbox $checkbox not ticked"; + } + + my @checkboxes; + + foreach my $name ( + grep { + ! $class->meta->get_attribute($_)->is_lazy + && ! defined $default->{$_} + } $self->attributes + ) { my $attr_type = ''; my $type = $name =~ m/^pass/ ? 'password' : 'text'; my $label = $name; - 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; - $value = $attr->default( $name ) if ! $value && $attr->has_default; + my $value = + defined $default->{$name} ? $default->{$name} : + $attr->has_default ? $attr->default( $name ) : + ''; if ( ref($config_params) eq 'HASH' ) { $value = $config_params->{$name}; @@ -134,6 +151,11 @@ $default->{$name} = $config_params->[0]->{$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{^Bool} ) { + my $suffix = ''; + $suffix = ' checked' if $value; + $value_html = qq||; + push @checkboxes, $name; } elsif ( $attr_type !~ m{^(Str|Int)$} ) { $value_html = qq||; } @@ -142,19 +164,23 @@ $default->{$name} = $value unless defined $default->{$name}; - if ( ! $value_html ) { - my $suffix = ''; - if ( $attr_type =~ m{^Bool$} ) { - $type = 'checkbox'; - $suffix = ' checked' if $value; - } - $value_html = qq||; - } + $value_html = qq|| unless $value_html; # warn "# required $name ", $class->meta->get_attribute( $name )->dump( 2 ); $form .= qq|| . $value_html; } - my $html = qq|

$class params

$form
|; + $form .= qq|| if @checkboxes; + + my $html; + + $html = qq| +

$class params

+
+ $form + +
+ | if $form; + $self->add_status({ $self->class => { params => $self->params,