Provide a way for Crud classes to autogenerate their forms.
This commit is contained in:
parent
c57649585a
commit
7a2745e792
2 changed files with 25 additions and 1 deletions
|
|
@ -24,6 +24,7 @@ use Tie::IxHash;
|
||||||
use Clone qw/clone/;
|
use Clone qw/clone/;
|
||||||
use WebGUI::DateTime;
|
use WebGUI::DateTime;
|
||||||
use WebGUI::Exception;
|
use WebGUI::Exception;
|
||||||
|
use WebGUI::HTMLForm;
|
||||||
|
|
||||||
has session => (
|
has session => (
|
||||||
is => 'ro',
|
is => 'ro',
|
||||||
|
|
@ -369,6 +370,29 @@ sub crud_dropTable {
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
|
=head2 crud_form ( $form, [$object] )
|
||||||
|
|
||||||
|
A class method to populate a WebGUI::HTMLForm object with all the fields for this Cruddy object.
|
||||||
|
|
||||||
|
=head3 $form
|
||||||
|
|
||||||
|
A WebGUI::HTMLForm object
|
||||||
|
|
||||||
|
=head3 $object
|
||||||
|
|
||||||
|
An object of this class, used to provide values to the form. It's optional.
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub crud_form {
|
||||||
|
my ($class, $form, $object) = @_;
|
||||||
|
my $properties = $class->crud_getProperties;
|
||||||
|
my $definition = [ { properties => $properties, }];
|
||||||
|
$form->dynamicForm($definition, 'properties', $object);
|
||||||
|
}
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
=head2 crud_getProperties ( )
|
=head2 crud_getProperties ( )
|
||||||
|
|
||||||
A management class method that returns just the 'properties' from the Crud'd definition.
|
A management class method that returns just the 'properties' from the Crud'd definition.
|
||||||
|
|
|
||||||
|
|
@ -277,7 +277,7 @@ sub www_editRule {
|
||||||
$form->hidden( name=>"op", value=>"passiveAnalytics");
|
$form->hidden( name=>"op", value=>"passiveAnalytics");
|
||||||
$form->hidden( name=>"func", value=>"editRuleSave");
|
$form->hidden( name=>"func", value=>"editRuleSave");
|
||||||
$form->hidden( name=>"ruleId", value=>$ruleId);
|
$form->hidden( name=>"ruleId", value=>$ruleId);
|
||||||
$form->dynamicForm([WebGUI::PassiveAnalytics::Rule->crud_definition($session)], 'properties', $rule);
|
$rule->crud_form($form, $rule);
|
||||||
$form->submit;
|
$form->submit;
|
||||||
|
|
||||||
my $i18n = WebGUI::International->new($session, 'PassiveAnalytics');
|
my $i18n = WebGUI::International->new($session, 'PassiveAnalytics');
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue