Skip to content

Commit

Permalink
don't access result directly in Select before 'value' method modifier
Browse files Browse the repository at this point in the history
  • Loading branch information
gshank committed May 16, 2011
1 parent e95858f commit 1fb6635
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/HTML/FormHandler/Field/Repeatable.pm
Expand Up @@ -296,6 +296,8 @@ before 'value' => sub {
my @pk_elems =
map { $_->accessor } grep { $_->has_flag('is_primary_key') } $self->contains->all_fields
if $self->contains->has_flag('is_compound');

return [] unless $self->has_value;
my $value = $self->result->value;
my @new_value;
foreach my $element ( @{$value} ) {
Expand Down
1 change: 1 addition & 0 deletions lib/HTML/FormHandler/Field/Select.pm
Expand Up @@ -461,6 +461,7 @@ sub sort_options { shift; return shift; }
before 'value' => sub {
my $self = shift;

return undef unless $self->has_result;
my $value = $self->result->value;

if( $self->multiple ) {
Expand Down
6 changes: 6 additions & 0 deletions t/circular_refs.t
Expand Up @@ -24,6 +24,12 @@ use Test::Memory::Cycle;
type => 'Text',
required => 1,
);
has_field 'some_select' => ( type => 'Select', inactive => 1 );

sub update_model {
my $self = shift;
my $value = $self->field('some_select')->value;
}
}

my $form = new_ok( 'My::RepeatableForm' );
Expand Down

0 comments on commit 1fb6635

Please sign in to comment.