diff --git a/docs/migration.txt b/docs/migration.txt index 7d004714f..da7f36653 100644 --- a/docs/migration.txt +++ b/docs/migration.txt @@ -23,20 +23,22 @@ You must migrate your asset to use the new WebGUI::Definition::Asset class inste 1) You pass your definition into use WebGUI::Definition::Asset ( def goes here ); -2) You no longer have a reference to $session, so you'll need to make sub routine refs to to method calls. +2) You no longer have a reference to $session, so you'll need to make sub routine refs to to method calls. However, you cannot use sub refs on any attributes or the following property elements: tableName, fieldType. -3) You no longer have customDrawMethod. You must make custom form controls. +3) You no longer have the "customDrawMethod" element. You must make custom form controls. 4) You no longer have filters. Instead, each property has a method called propertyName (so a property called 'title' would be title()). You can override that to achieve the same result. 5) Because you don't have a reference to $session, you can't internationalize right in the definition. So property elements like "label" and "hoverHelp" are just i18n identifiers and will automatically be run through internationalization on calling the getProperty() method. -6) Definition's are now rigid. This means that every property needs to be defined in the definition, and it must at least have a "fieldType" element. If the field is to be displayed (ie: it doesn't have a noFormPost=>1 element) then it must also at minimum have label and hoverHelp elements. In addition, you must specify assetName, tableName, and properties attributes at minimum. Anything less is invalid. +6) Definition's are now rigid. This means that every property needs to be defined in the definition, and it must at least have a "fieldType" element. If the field is to be displayed (ie: it doesn't have a noFormPost=>1 element) then it must also at minimum have label elements. In addition, you must specify assetName, tableName, and properties attributes at minimum. Anything less is invalid. 7) The properties attribute must be an array reference of properties. No more Tie::IxHash. 8) The autoGenerateForms has been removed. All edit forms are autogenerated in WebGUI 8. +9) You no longer have the "visible" element. It was a duplicate of "noFormPost", so use "noFormPost" instead. + Here's an example. use WebGUI::Definition::Asset ( diff --git a/lib/WebGUI/Asset.pm b/lib/WebGUI/Asset.pm index c71eafd2b..609b71a96 100644 --- a/lib/WebGUI/Asset.pm +++ b/lib/WebGUI/Asset.pm @@ -84,10 +84,11 @@ use WebGUI::Definition::Asset ( defaultValue =>0, }, encryptPage=>{ - fieldType => + fieldType => 'yesNo', + noFormPost => sub { my $self = shift; - return $self->session->config->get("sslEnabled") ? 'yesNo' : 'hidden'; + return $self->session->config->get("sslEnabled"); }, tab => "security", label => ['encrypt page','Asset'], @@ -907,13 +908,9 @@ sub getEditForm { $params{value} = [$params{value}]; } - if (exists $fieldHash{visible} and not $fieldHash{visible}) { - $params{fieldType} = 'hidden'; - } - else { - %params = (%params, %fieldHash); - delete $params{tab}; - } + %params = (%params, %fieldHash); + delete $params{tab}; + delete $params{tableName}; # if there isnt a tab specified lets define one my $tab = $fieldHash{tab} || "properties"; @@ -1585,10 +1582,11 @@ sub new { } my $properties = eval{$session->cache->get(["asset",$assetId,$revisionDate])}; - unless (exists $properties->{assetId}) { + unless (exists $properties->{assetId}) { # can we get it from cache? my $sql = "select * from asset"; my $where = " where asset.assetId=?"; my $placeHolders = [$assetId]; + foreach my $definition (@{$class->definition($session)}) { $sql .= ",".$definition->{tableName}; $where .= " and (asset.assetId=".$definition->{tableName}.".assetId and ".$definition->{tableName}.".revisionDate=".$revisionDate.")";