1.0 Problem
Multiple-Choice Checkboxes are not filled from the according CiviCRM Entity on Webform load.
Seems to have something to do with custom field of the relation ship.
2.0 Detailed steps to reproduce
I have a Custom Data Group used for the relation between two Contacts. One Custom Data Field is a multiple Choice, for languages (Data Type: Alphanumeric, Field Input Type: Checkboxes)
The Options look like:
Labels: Englisch, Deutsch,...
Values: Englisch, Deutsch,...
I add this to a Drupal civicrm webform through the common method of clicking the according check box in the CiviCRM tab.
Config for this element looks like this:
civicrm_3_contact_2_relationship_custom_334:
'#type': civicrm_options
'#title': 'vereinbarte Sprachen'
'#prepopulate': true
'#options':
Englisch: Englisch
Spanisch: Spanisch
Französisch: Französisch
Italienisch: Italienisch
Polnisch: Polnisch
Portugiesisch: Portugiesisch
Rumänisch: Rumänisch
Vietnamesisch: Vietnamesisch
Türkisch: Türkisch
Äthiopisch: Äthiopisch
Russisch: Russisch
Ukrainisch: Ukrainisch
Urdu: Urdu
Arabisch: Arabisch
Farsi: Farsi
Kurdisch: Kurdisch
'#states_clear': false
'#default_value':
- '[current-page:url:args:value:civicrm_3_contact_2_relationship_custom_334]'
'#attributes':
data-relationship-type: '23'
'#extra':
aslist: 0
multiple: 1
'#data_type': String
'#has_help': true
'#form_key': civicrm_3_contact_2_relationship_custom_334
'#parent': civicrm_3_contact_2_relationship_fieldset
'#exposed_empty_option': ''
'#default_option': ''
'#civicrm_live_options': '1'
Now I can set using multiple choice the language. So it is the right field and entity.
However on entering the webform the checkboxes are not set, or filled from the entity. Any other field like Custom Data Fields text or date are filled correctly.
I can preset exactly one language by adding: "?civicrm_3_contact_2_relationship_custom_334=Englisch" to the URL
3.0 Proposed resolution
I tried debugging the problem, and found that after WebformCivicrmPreProcess::fillForm is called, the default_value contains the correct values, which should be set.
So it has to be somewhere behind that.
I'm stug with debugging the js and not that confident by now, how loading default_value to the html element works...
UPDATE
I tried to narrow down the issue.
I found that the problem only occures, with optiongroups of custom fields of RELATIONSHIPS.
When I add the same custom data group to the contact then it works all nicely.
Issue fork webform_civicrm-3494307
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3494307-multiple-choice-checkboxes-are
changes, plain diff MR !20
Comments
Comment #2
pklausing commentedComment #3
luke.stewart commentedJust to confirm - you have narrowed this down to custom fields of (Data Type: Alphanumeric, Field Input Type: Checkboxes) but only on a relationship? You mention other custom fields working just confirming you tested other custom field types on relationships as wasn't clear above.
Comment #4
pklausing commentedYes I used text and numbers on relationship works everything fine.
However I see, that #default_value is set correctly in WebformCivicrmPreProcess::fillForm.
Comment #6
pklausing commentedI found that the problem is how apiv3 outputs custom fields for relationships. I published a fix in a merge request.
Comment #7
karingComment #8
karingCan you please put up a PR on the github repo: https://github.com/colemanw/webform_civicrm
Also this will need a test - similar to examples in here: https://github.com/colemanw/webform_civicrm/blob/6.x/tests/src/Functiona...
It could also be added here: https://github.com/colemanw/webform_civicrm/blob/6.x/tests/src/Functiona...
I'm traveling / visiting with a client this week. And working on Drupal 7 -> Drupal 10 upgrades at night. Sorry, I don't have much bandwidth to help out until after Jan 05.
Comment #10
karingFixed in 6.3.1