Use compound fields for element groups.

agranig/1_0_subfix
Andreas Granig 12 years ago
parent 460ecd825b
commit 61f57290ed

@ -1,22 +1,20 @@
package NGCP::Panel::Field::Contract;
use Moose;
extends 'HTML::FormHandler::Field::Select';
use HTML::FormHandler::Moose;
extends 'HTML::FormHandler::Field::Compound';
use Data::Dumper;
has_field 'foo' => (
type => '+NGCP::Panel::Field::ContractSelect',
label => 'Contract',
required => 1,
);
sub build_options {
my ($self) = @_;
return [
{ label => 'Select...', value => '' },
{ label => '1', value => 1 },
{ label => '2', value => 2 },
{ label => '3', value => 3 },
{ label => '4', value => 4 },
{ label => '5', value => 5 },
{ label => '6', value => 6 },
];
}
has_field 'create' => (
type => 'Button',
label => 'or',
value => 'Create Contract',
element_attr => { onclick => 'window.location=\'/contract/create\'' },
element_class => [qw/btn btn-tertiary/],
);
1;

@ -0,0 +1,21 @@
package NGCP::Panel::Field::ContractSelect;
use Moose;
extends 'HTML::FormHandler::Field::Select';
sub build_options {
my ($self) = @_;
return [
{ label => 'Select...', value => '' },
{ label => '1', value => 1 },
{ label => '2', value => 2 },
{ label => '3', value => 3 },
{ label => '4', value => 4 },
{ label => '5', value => 5 },
{ label => '6', value => 6 },
];
}
1;
# vim: set tabstop=4 expandtab:

@ -10,8 +10,10 @@ has '+widget_wrapper' => ( default => 'Bootstrap' );
sub build_render_list {[qw/fields actions/]}
sub build_form_element_class { [qw/form-horizontal/] }
has_field 'id' => (
type => 'Hidden',
has_field 'contract' => (
type => '+NGCP::Panel::Field::Contract',
label => 'Contract',
not_nullable => 1,
);
has_field 'name' => (
@ -19,11 +21,6 @@ has_field 'name' => (
required => 1,
);
has_field 'contract_id' => (
type => '+NGCP::Panel::Field::Contract',
label => 'Contract',
required => 1,
);
has_field 'status' => (
type => 'Text',
@ -40,7 +37,7 @@ has_field 'save' => (
has_block 'fields' => (
tag => 'div',
class => [qw/modal-body/],
render_list => [qw/id contract_id name status/],
render_list => [qw/contract name status/],
);
has_block 'actions' => (

Loading…
Cancel
Save