diff --git a/lib/WebGUI/Definition.pm b/lib/WebGUI/Definition.pm index 58dc4da1e..03fa24104 100644 --- a/lib/WebGUI/Definition.pm +++ b/lib/WebGUI/Definition.pm @@ -125,10 +125,22 @@ An options hashref [need list of base options]. Any option which belongs to a f is relegated to the form attribute of the property and removed from the list of regular attributes. +=head4 fieldType + +The type of field to be created by the form builder. This is required, and should be the name of +a WebGUI::Form plugin, with the initial letter lowercased. + +=head4 noFormPost, label + +Either or both of these must be passed in. + =cut sub property { my ($meta, $name, %options) = @_; + if (! (exists $options{noFormPost} || exists $options{label}) ) { + Moose->throw_error("Must pass either noFormPost or label when making a property"); + } my %form_options; my $prop_meta = $meta->property_meta; for my $key ( keys %options ) { diff --git a/lib/WebGUI/Definition/Meta/Property/Asset.pm b/lib/WebGUI/Definition/Meta/Property/Asset.pm index 2561f88d0..f1e133ab4 100644 --- a/lib/WebGUI/Definition/Meta/Property/Asset.pm +++ b/lib/WebGUI/Definition/Meta/Property/Asset.pm @@ -28,7 +28,7 @@ Package WebGUI::Definition::Meta::Property::Asset =head1 DESCRIPTION Extends WebGUI::Definition::Meta::Property to provide Asset properties with -specific methods. +specific methods. The tableName and fieldType class properties must be defined. =head1 METHODS diff --git a/t/Definition.t b/t/Definition.t index 0c03413fa..1b5bb3a83 100644 --- a/t/Definition.t +++ b/t/Definition.t @@ -24,9 +24,11 @@ my $called_getProperties; attribute 'attribute1' => 'attribute1 value'; property 'property1' => ( arbitrary_key => 'arbitrary_value', + label => 'property1', ); property 'property2' => ( nother_key => 'nother_value', + label => 'property2', ); # attributes create methods @@ -62,7 +64,18 @@ my $called_getProperties; use WebGUI::Definition::Asset; attribute tableName => 'asset'; - ::dies_ok { property 'property1' => (); } 'must have a fieldType'; + ::dies_ok { property 'property1' => (); } 'must have a fieldType'; + ::dies_ok { property 'property1' => (fieldType => 'text'); } 'must pass either a label or noFormPost flag'; + ::lives_ok { property 'property1' => ( + fieldType => 'YUI Super Form', + noFormPost => '1', + ); + } '... pass noFormPost flag'; + ::lives_ok { property 'property1' => ( + fieldType => 'YUI Super Form', + label => 'JSON Powered Uber Widget', + ); + } '... pass label'; } @@ -73,9 +86,11 @@ my $called_getProperties; attribute tableName => 'asset'; property 'property2' => ( fieldType => 'text', + label => 'property2', ); property 'property1' => ( fieldType => 'text', + label => 'property1', ); my $written; @@ -143,13 +158,16 @@ my $called_getProperties; attribute tableName => 'asset'; property 'property1' => ( - fieldType => 'text' + fieldType => 'text', + label => 'property1', ); property 'property2' => ( - fieldType => 'text' + fieldType => 'text', + label => 'property2', ); property 'property3' => ( - fieldType => 'text' + fieldType => 'text', + label => 'property3', ); package WGT::Class::Asset::Snippet; @@ -158,10 +176,12 @@ my $called_getProperties; attribute tableName => 'snippet'; property 'property10' => ( - fieldType => 'text' + fieldType => 'text', + label => 'property10', ); property 'property11' => ( - fieldType => 'text' + fieldType => 'text', + label => 'property11', ); package main; @@ -200,9 +220,11 @@ my $called_getProperties; attribute tableName => 'snippet'; property 'property10' => ( fieldType => 'text', + label => 'property10', ); property 'property1' => ( fieldType => 'text', + label => 'property1', ); package main;