- Issue created by @tomasbarej
- πΈπ°Slovakia tomasbarej
I was able to fix the behaviour, but I'm not so confident about the resolution because I don't really get how it might actually work before.
There is an initialisation of a plugin in QuizTrait.php with a method createWebformScorePlugin:
$plugin = $this->createWebformScorePlugin($this->configuration, $score_methodology_option);
First argument of the method should be an element where settings of the plugin should be loaded from element property #webform_score_plugin_configuration
protected function createWebformScorePlugin(array $element, $plugin_id = NULL) { if (!$plugin_id) { $plugin_id = $this->getElementProperty($element, 'webform_score_plugin'); } return $this->webformScoreManager->createInstance($plugin_id, $this->getElementProperty($element, 'webform_score_plugin_configuration')); }
It doesn't make sense to me to pass a $this->configuration array when there are not (or should not be) an element property.
It starts working when I pass an actual element props the method expects in form or an $element array like this:
$element = [ '#webform_score_plugin' => $score_methodology_option, '#webform_score_plugin_configuration' => $current_plugin_config, ]; $plugin = $this->createWebformScorePlugin($element, $score_methodology_option);
What I'm not sure are the two more occurrences of plugin initialisation
$plugin = $this->createWebformScorePlugin($this->configuration, $score_methodology_option);
in methods validateConfigurationForm and submitConfigurationForm and wondering if it actually might validate or submit the values. In order to save config we need patch posted in issue https://www.drupal.org/project/webform_score/issues/2913371 π The score configuration is not saved Needs review - Status changed to Needs review
10 months ago 9:46am 24 January 2024 - Merge request !6Issue #3416651: Fixed initialisation of stored plugin configuration. β (Open) created by tomasbarej
- π¦πΊAustralia Nigel Cunningham Geelong
Thanks for opening this issue. I've just pushed some work that I've done over the last few days - as you rightly pointed out, more was needed than just fixing the arguments. I'll credit your work on this when I get up to closing the issue. In the meantime, if you'd like to try the current dev branch, it will hopefully fix issues for you.