TT#38811 fix validate_fields to include Subfields of Compound

Change-Id: I073232e4e1bd35606f4d31be9b06dd14054e4d5a
changes/72/22372/5
Gerhard Jungwirth 7 years ago
parent f2e533c90d
commit 26435acacd

@ -21,12 +21,44 @@ has_field 'destinations.announcement_id' => (
type => 'PosInteger',
);
has_field 'destinations.simple_destination' => (
type => 'Text',
);
has_field 'destinations.priority' => (
type => 'Integer',
);
has_field 'times' => (
type => 'Repeatable',
do_wrapper => 1,
do_label => 0,
);
has_field 'times.hour' => (
type => 'Text',
);
has_field 'times.mday' => (
type => 'Text',
);
has_field 'times.minute' => (
type => 'Text',
);
has_field 'times.month' => (
type => 'Text',
);
has_field 'times.wday' => (
type => 'Text',
);
has_field 'times.year' => (
type => 'Text',
);
has_field 'sources' => (
type => 'Repeatable',
do_wrapper => 1,

@ -4,7 +4,6 @@ use HTML::FormHandler::Moose;
extends 'HTML::FormHandler';
use HTML::FormHandler::Widget::Block::Bootstrap;
use NGCP::Panel::Field::BillingZone;
has '+widget_wrapper' => ( default => 'Bootstrap' );
has_field 'submitid' => ( type => 'Hidden' );

@ -315,6 +315,15 @@ sub validate_fields {
}
}
}
if (defined $resource->{$k} &&
$fields->{$k}->$_isa('HTML::FormHandler::Field::Compound') &&
"HASH" eq ref $resource->{$k}) {
my @compound_subfields = $fields->{$k}->fields;
if (@compound_subfields) {
my %subfields = map { $_->name => $_ } @compound_subfields;
$self->validate_fields($c, $resource->{$k}, \%subfields, $run);
}
}
# only do this for converting back from obj to hal
# otherwise it breaks db fields with the \0 and \1 notation

Loading…
Cancel
Save