flow-development-collection icon indicating copy to clipboard operation
flow-development-collection copied to clipboard

Multiple AjaxWidgets on one Site seems to use the same WidgetContext...

Open nixahnung opened this issue 7 years ago • 2 comments

I use the (same) AjaxWidget multiple times in the same template. Problem seems that all generated widgets had the same widgetContext (despite different widgetIds)

Result: all Widgets have the same (last widgets) Content...

Reason: I think the Reason is in AjaxWidgetContextHolder.php Line 72: $this->widgetContexts[$ajaxWidgetId] = $widgetContext; (because there is just stored an objectreference in that array instead of cloning)

Workarround: AbstractWidgetViewHelper.php has an function called resetState() which seems to correct that issue. Should be called in initializeArgumentsAndRender() (or some better place) for AjaxWidgets...

Flow: 4.3.3

nixahnung avatar Feb 15 '18 10:02 nixahnung

Issue still exists in Flow 5.3.8

cornerfarmer avatar Nov 19 '19 21:11 cornerfarmer

@nixahnung I personally do this A LOT (from Flow 3 to 6) and never experencied that behavior. Could you gist somewhere an example widget, that will show this behavior if instantiated multiple times?

fcool avatar Aug 31 '21 18:08 fcool

If this happens in a ForViewHelper than we have encountered this problem, too. The reason for this is that only one instance of the WidgetViewHelper will be created and therefore the later occurancies overwrites the ones before.

gelidium-incendium avatar Apr 29 '23 16:04 gelidium-incendium