The answers in the questionnaire where wrong if the answers where reordered in the salsa backend.
Also the default value for fields with multiple values was not noted.
I also put the fields each in one container and added a little more documentation to understand how the salsa options where parsed etc.
Comments
Comment #1
LukyLuke_ch commentedMissed that the question key in the container must be the same as before and not the container.
Comment #2
s_leu commentedFor single additions to the array I suggest using $element['#default_value'] rather than += array()
After applying the patch and visiting a site with a questionnaire, this code threw notices. Guess the split by ~ should happen outside of the condition. The condition should also check if default[1] contains anything.
Comment #3
LukyLuke_ch commentedThe operator "+=" on arrays adds the new values only if they not already exists - the "$a[]" adds them and overrides existing what we not want here. This is a short version of "$element = array_merge(array('foo' => 'bar'), $element)".
What notices do you get here and on which line? On the explode, the condition or by accessing on the key 1?
In general: We first need to check if there is a "Default_Value", after we can split this up in the various parts, no?
If the "Default_Value" is provided the right way from salsa (and the questionnaire is configured correctly), then there should be no problem with this. The first index holds the field_label and the second the field_name. So if the user has not entered a label for the option, there should also be an empty string in the frontend - also for the default value.
Comment #4
s_leu commentedThe problem is that you just used the same default value without considering the element type. Elements of type "checkboxes" expect an array instead of a string. Adding a new patch that considers this.
Comment #6
berdirPatch contains stuff from another issue.