Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PRESIDECMS-2949 Existing oneToManyConfigurator field value does not show when editing #1541

Open
wants to merge 2 commits into
base: stable
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion system/handlers/formcontrols/OneToManyConfigurator.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ component {
var sourceIdField = presideObjectService.getIdField( args.sourceObject );
var sortOrderField = presideObjectService.getObjectAttribute( targetObject, "datamanagerSortField", "sort_order" );
var hasSortOrder = StructKeyExists( presideObjectService.getObjectProperties( targetObject ), sortOrderField );
var isEdit = isEmptyString( args.savedData[ "datecreated" ] ?: "" );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This naming seems the wrong way around? isEdit should be = !isEmptyString( ... )? and then the logic below would be if ( isEdit || isTrue( sourceProperty.cloneable...?

I wonder should it all be simpler and just use if ( !StructIsEmpty( args.savedData ) )? i.e. if we have saved data, whether cloning or editing, then we should prepopulate?

I'm curious that this would not have been picked up previously re the bug in general. Wonder if @sebduggan has any thoughts here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue was only introduced with the previous bugfix from last month...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am afraid we cannot use !StructIsEmpty(args.savedData) because the cloned args.savedData is not empty, but it is missing datecreated and datemodified.


args.labelRenderer = args.labelRenderer ?: presideObjectService.getObjectAttribute( targetObject, "labelRenderer" );

Expand All @@ -22,7 +23,7 @@ component {
logError( e );
}

if ( isTrue( sourceProperty.cloneable ?: true ) ) {
if ( !isEdit || isTrue( sourceProperty.cloneable ?: true ) ) {
args.defaultValue = args.savedValue = presideObjectService.getOneToManyConfiguratorJsonString(
sourceObject = args.sourceObject
, sourceId = args.savedData[ sourceIdField ] ?: ""
Expand Down