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

fix stars/notes functionality when country_id is in submission #959

Merged

Conversation

MegaphoneJon
Copy link
Contributor

Overview

@jitendrapurohit removed this from #880, and it failed tests. But I've found a bug caused by this code.

fillCiviCRMData() is called when:

  • Rendering tokens
  • Loading webform submissions
  • Editing webform submissions via AJAX (by adding the star or notes from the submissions tab).

We thought the latter two were unnecessary, since Webform calls the token renderer when loading this page. So we removed it, and it failed a test. But in the third case, it's called before the data is saved, so for any option value fields, we pass the label as the ID.

Many fields will accept this. country_id will not. So you get a 500 error on any AJAX webform submission stars/notes when the country is present.

I'm submitting this so I can see the exact tests that are failing and see if there's a resolution.

@MegaphoneJon MegaphoneJon force-pushed the fix-ajax-submission-edits branch 2 times, most recently from 19b20e5 to 3ca416a Compare April 19, 2024 15:40
@MegaphoneJon
Copy link
Contributor Author

That test fail on dev-master looks unrelated, but let me know if not.

This fixes using the "stars" and "notes" function on submissions that have WFC and certain option IDs, in my case country_id.

_fillCiviCRMData() is called from two places - when rendering tokens and loading webform submissions. But it does two distinct tasks, and each place only uses the data from one task. Consider a form that asks for name, gender and country. When the function begins, $webformSubmission->data will be something like this:

[
'civicrm_1_contact_1_first_name' => 'Jon',
'civicrm_1_contact_1_last_name' => 'Goldberg',
'civicrm_1_contact_1_address_country_id' => '1228',
'civicrm_1_contact_1_gender_id' => '2',
]

Before data is saved to Civi, this will return:

[
  'civicrm_1_contact_1_contact_first_name' => 'Jon',
  'civicrm_1_contact_1_contact_last_name' => 'Goldberg',
  'civicrm_1_contact_1_address_country_id' => 'United States',
  'civicrm_1_contact_1_contact_gender_id' => 'Male',
  'civicrm_data_loaded' => true,
  'civicrm_1_contact_1_address_country_id_raw' => '1228',
  'civicrm_1_contact_1_contact_gender_id_raw' => '2',
]

Once the data is saved to Civi, it will be this:

[
  'civicrm_1_contact_1_address_country_id' => 'United States',
  'civicrm_1_contact_1_contact_first_name' => 'Jon',
  'civicrm_1_contact_1_contact_gender_id' => 'Male',
  'civicrm_1_contact_1_contact_last_name' => 'Goldberg',
  'civicrm_1_contact_1_address_country_id_raw' => '1228',
  'civicrm_1_contact_1_contact_gender_id_raw' => '2',
  'civicrm' => [
    'contact' => [
      1 => [
        'id' => '2',
        'display_name' => 'Mr. Jon Goldberg',
      ],
    ],
  ],
]

Rendering tokens uses both $data['civicrm'] and the other $data elements, but loading submissions only needs $data['civicrm']. The presence of the other values in rednered form (United States, Male, etc.) breaks resubmission, because it passes the label to API3 as the ID. Sometimes API3 accepts labels instead of IDs, sometimes it doesn't. This PR separates the two tasks into two functions, and we only call the part that generates $data['civicrm'] when loading submissions.

@MegaphoneJon MegaphoneJon force-pushed the fix-ajax-submission-edits branch from 3ca416a to 1bcfdf2 Compare April 19, 2024 18:05
@jitendrapurohit
Copy link
Collaborator

ok I was able to replicate this with

  • A webform having Contact + Address fields.
  • Submit the webform with all values.
  • Visit the results page and try to star the submission => Error.
  • Visit the Notes tab and save the form => Error (Also returns error if note is added from the icon on the result row)
  • image

Applied the patch

  • Notes and star functionality is fixed.

But state field is returning id instead of name.

image

It displays the name correctly before the patch.

@MegaphoneJon
Copy link
Contributor Author

Thanks @jitendrapurohit. I'll write tests for this. I wasn't seeing this in my testing but that probably means there's a workflow I'm not considering.

@MegaphoneJon
Copy link
Contributor Author

@jitendrapurohit I wasn't able to replicate this issue, and in fact in testing I found that the patch fixes a different bug.

Below is my form (apologies it's so long, the clientside_validation module is at fault).

I submitted data, and it's rendering correctly on the "results" page. Additionally, if I click Edit next to the result, the state/province displays. It comes up blank without this patch.

Selection_2227

Selection_2228

uuid: 45af4110-8d0b-4c5d-ae45-8258ccf8448f
langcode: en
status: open
dependencies:
  module:
    - webform_civicrm
weight: 0
open: null
close: null
uid: 461
template: false
archive: false
id: star_test
title: 'Star Test'
description: 'for testing only'
categories:
  - 'Paid Registration'
elements: |-
  contact_pagebreak:
    '#type': webform_wizard_page
    '#form_key': contact_pagebreak
    '#title': 'Contact Information'
    civicrm_1_contact_1_fieldset_fieldset:
      '#type': fieldset
      '#title': 'Contact 1'
      '#form_key': civicrm_1_contact_1_fieldset_fieldset
      '#parent': contact_pagebreak
      civicrm_1_contact_1_contact_first_name:
        '#type': textfield
        '#counter_type': character
        '#counter_maximum': 64
        '#counter_maximum_message': ' '
        '#contact_type': individual
        '#form_key': civicrm_1_contact_1_contact_first_name
        '#extra':
          width: 20
        '#parent': civicrm_1_contact_1_fieldset_fieldset
        '#title': 'First Name'
        '#required': true
      civicrm_1_contact_1_contact_last_name:
        '#type': textfield
        '#counter_type': character
        '#counter_maximum': 64
        '#counter_maximum_message': ' '
        '#contact_type': individual
        '#form_key': civicrm_1_contact_1_contact_last_name
        '#extra':
          width: 20
        '#parent': civicrm_1_contact_1_fieldset_fieldset
        '#title': 'Last Name'
        '#required': true
      civicrm_1_contact_1_address_country_id:
        '#type': civicrm_options
        '#extra':
          aslist: 1
          items: |-
            1228|United States
            1002|Albania
            1003|Algeria
            1005|Andorra
            1010|Argentina
            1011|Armenia
            1013|Australia
            1014|Austria
            1212|Bahamas
            1016|Bahrain
            1017|Bangladesh
            1019|Belarus
            1020|Belgium
            1023|Bermuda
            1029|Brazil
            1033|Bulgaria
            1039|Canada
            1041|Cayman Islands
            1044|Chile
            1045|China
            1053|Costa Rica
            1057|Cyprus
            1058|Czech Republic
            1059|Denmark
            1065|Egypt
            1066|El Salvador
            1069|Estonia
            1070|Ethiopia
            1075|Finland
            1076|France
            1080|Gabon
            1081|Georgia
            1082|Germany
            1085|Greece
            1094|Haiti
            1098|Hong Kong
            1099|Hungary
            1101|India
            1103|Iran, Islamic Republic Of
            1104|Iraq
            1105|Ireland
            1106|Israel
            1107|Italy
            1109|Japan
            1110|Jordan
            1111|Kazakhstan
            1115|Korea, Republic of
            1116|Kuwait
            1119|Latvia
            1120|Lebanon
            1125|Lithuania
            1126|Luxembourg
            1131|Malaysia
            1140|Mexico
            1143|Monaco
            1146|Morocco
            1152|Netherlands
            1154|New Zealand
            1128|North Macedonia
            1161|Norway
            1169|Peru
            1170|Philippines
            1172|Poland
            1173|Portugal
            1175|Qatar
            1176|Romania
            1177|Russian Federation
            1187|Saudi Arabia
            1242|Serbia
            1191|Singapore
            1192|Slovakia
            1196|South Africa
            1198|Spain
            1200|Sudan
            1204|Sweden
            1205|Switzerland
            1206|Syrian Arab Republic
            1208|Taiwan
            1211|Thailand
            1214|Togo
            1219|Turkey
            1220|Turkmenistan
            1224|Ukraine
            1225|United Arab Emirates
            1226|United Kingdom
            1229|Uruguay
            1230|Uzbekistan
            1231|Vanuatu
            1232|Venezuela
            1234|Virgin Islands, U.S.
        '#form_key': civicrm_1_contact_1_address_country_id
        '#options':
          1228: 'United States'
          1002: Albania
          1003: Algeria
          1005: Andorra
          1010: Argentina
          1011: Armenia
          1013: Australia
          1014: Austria
          1212: Bahamas
          1016: Bahrain
          1017: Bangladesh
          1019: Belarus
          1020: Belgium
          1023: Bermuda
          1029: Brazil
          1033: Bulgaria
          1039: Canada
          1041: 'Cayman Islands'
          1044: Chile
          1045: China
          1053: 'Costa Rica'
          1057: Cyprus
          1058: 'Czech Republic'
          1059: Denmark
          1065: Egypt
          1066: 'El Salvador'
          1069: Estonia
          1070: Ethiopia
          1075: Finland
          1076: France
          1080: Gabon
          1081: Georgia
          1082: Germany
          1085: Greece
          1094: Haiti
          1098: 'Hong Kong'
          1099: Hungary
          1101: India
          1103: 'Iran, Islamic Republic Of'
          1104: Iraq
          1105: Ireland
          1106: Israel
          1107: Italy
          1109: Japan
          1110: Jordan
          1111: Kazakhstan
          1115: 'Korea, Republic of'
          1116: Kuwait
          1119: Latvia
          1120: Lebanon
          1125: Lithuania
          1126: Luxembourg
          1131: Malaysia
          1140: Mexico
          1143: Monaco
          1146: Morocco
          1152: Netherlands
          1154: 'New Zealand'
          1128: 'North Macedonia'
          1161: Norway
          1169: Peru
          1170: Philippines
          1172: Poland
          1173: Portugal
          1175: Qatar
          1176: Romania
          1177: 'Russian Federation'
          1187: 'Saudi Arabia'
          1242: Serbia
          1191: Singapore
          1192: Slovakia
          1196: 'South Africa'
          1198: Spain
          1200: Sudan
          1204: Sweden
          1205: Switzerland
          1206: 'Syrian Arab Republic'
          1208: Taiwan
          1211: Thailand
          1214: Togo
          1219: Turkey
          1220: Turkmenistan
          1224: Ukraine
          1225: 'United Arab Emirates'
          1226: 'United Kingdom'
          1229: Uruguay
          1230: Uzbekistan
          1231: Vanuatu
          1232: Venezuela
          1234: 'Virgin Islands, U.S.'
        '#parent': civicrm_1_contact_1_fieldset_fieldset
        '#title': Country
        '#civicrm_live_options': 1
      civicrm_1_contact_1_contact_gender_id:
        '#type': civicrm_options
        '#contact_type': individual
        '#form_key': civicrm_1_contact_1_contact_gender_id
        '#options':
          1: Female
          2: Male
          3: Other
        '#extra':
          items: |-
            1|Female
            2|Male
            3|Other
          aslist: false
        '#parent': civicrm_1_contact_1_fieldset_fieldset
        '#title': Gender
        '#civicrm_live_options': 0
      civicrm_1_contact_1_address_state_province_id:
        '#type': civicrm_options
        '#extra':
          aslist: 1
        '#data_type': state_province_abbr
        '#empty_option': '- None -'
        '#form_key': civicrm_1_contact_1_address_state_province_id
        '#parent': civicrm_1_contact_1_fieldset_fieldset
        '#title': State/Province
        '#civicrm_live_options': 0
        '#options': {  }
css: ''
javascript: ''
settings:
  ajax: false
  ajax_scroll_top: form
  ajax_progress_type: ''
  ajax_effect: ''
  ajax_speed: null
  page: true
  page_submit_path: ''
  page_confirm_path: ''
  page_theme_name: ''
  form_title: both
  form_submit_once: false
  form_open_message: ''
  form_close_message: ''
  form_exception_message: ''
  form_previous_submissions: true
  form_confidential: false
  form_confidential_message: ''
  form_disable_remote_addr: false
  form_convert_anonymous: false
  form_prepopulate: false
  form_prepopulate_source_entity: false
  form_prepopulate_source_entity_required: false
  form_prepopulate_source_entity_type: ''
  form_unsaved: false
  form_disable_back: false
  form_submit_back: false
  form_disable_autocomplete: false
  form_novalidate: false
  form_disable_inline_errors: false
  form_required: false
  form_autofocus: false
  form_details_toggle: false
  form_reset: false
  form_access_denied: default
  form_access_denied_title: ''
  form_access_denied_message: ''
  form_access_denied_attributes: {  }
  form_file_limit: ''
  form_attributes: {  }
  form_method: ''
  form_action: ''
  share: false
  share_node: false
  share_theme_name: ''
  share_title: true
  share_page_body_attributes: {  }
  submission_label: ''
  submission_exception_message: ''
  submission_locked_message: ''
  submission_log: false
  submission_excluded_elements: {  }
  submission_exclude_empty: false
  submission_exclude_empty_checkbox: false
  submission_views: {  }
  submission_views_replace: {  }
  submission_user_columns: {  }
  submission_user_duplicate: false
  submission_access_denied: default
  submission_access_denied_title: ''
  submission_access_denied_message: ''
  submission_access_denied_attributes: {  }
  previous_submission_message: ''
  previous_submissions_message: ''
  autofill: false
  autofill_message: ''
  autofill_excluded_elements: {  }
  wizard_progress_bar: true
  wizard_progress_pages: false
  wizard_progress_percentage: false
  wizard_progress_link: false
  wizard_progress_states: false
  wizard_start_label: ''
  wizard_preview_link: false
  wizard_confirmation: true
  wizard_confirmation_label: ''
  wizard_auto_forward: true
  wizard_auto_forward_hide_next_button: false
  wizard_keyboard: true
  wizard_track: ''
  wizard_prev_button_label: ''
  wizard_next_button_label: ''
  wizard_toggle: false
  wizard_toggle_show_label: ''
  wizard_toggle_hide_label: ''
  wizard_page_type: container
  wizard_page_title_tag: h3
  preview: 0
  preview_label: ''
  preview_title: ''
  preview_message: ''
  preview_attributes: {  }
  preview_excluded_elements: {  }
  preview_exclude_empty: true
  preview_exclude_empty_checkbox: false
  draft: none
  draft_multiple: false
  draft_auto_save: false
  draft_saved_message: ''
  draft_loaded_message: ''
  draft_pending_single_message: ''
  draft_pending_multiple_message: ''
  confirmation_type: page
  confirmation_url: ''
  confirmation_title: 'Thank you'
  confirmation_message: 'This is a confirmation message: Success!'
  confirmation_attributes: {  }
  confirmation_back: true
  confirmation_back_label: ''
  confirmation_back_attributes: {  }
  confirmation_exclude_query: false
  confirmation_exclude_token: false
  confirmation_update: false
  limit_total: null
  limit_total_interval: null
  limit_total_message: ''
  limit_total_unique: false
  limit_user: null
  limit_user_interval: null
  limit_user_message: ''
  limit_user_unique: false
  entity_limit_total: null
  entity_limit_total_interval: null
  entity_limit_user: null
  entity_limit_user_interval: null
  purge: none
  purge_days: null
  results_disabled: false
  results_disabled_ignore: false
  results_customize: false
  token_view: false
  token_update: false
  token_delete: false
  serial_disabled: false
access:
  create:
    roles:
      - anonymous
      - authenticated
    users: {  }
    permissions: {  }
  view_any:
    roles: {  }
    users: {  }
    permissions: {  }
  update_any:
    roles: {  }
    users: {  }
    permissions: {  }
  delete_any:
    roles: {  }
    users: {  }
    permissions: {  }
  purge_any:
    roles: {  }
    users: {  }
    permissions: {  }
  view_own:
    roles: {  }
    users: {  }
    permissions: {  }
  update_own:
    roles: {  }
    users: {  }
    permissions: {  }
  delete_own:
    roles: {  }
    users: {  }
    permissions: {  }
  administer:
    roles: {  }
    users: {  }
    permissions: {  }
  test:
    roles: {  }
    users: {  }
    permissions: {  }
  configuration:
    roles: {  }
    users: {  }
    permissions: {  }
handlers:
  webform_civicrm:
    id: webform_civicrm
    handler_id: webform_civicrm
    label: CiviCRM
    notes: ''
    status: true
    conditions: {  }
    weight: null
    settings:
      nid: 1
      number_of_contacts: '1'
      1_contact_type: individual
      1_webform_label: 'Contact 1'
      civicrm_1_contact_1_contact_contact_sub_type: {  }
      civicrm_1_contact_1_contact_existing: 0
      civicrm_1_contact_1_contact_prefix_id: 0
      civicrm_1_contact_1_contact_first_name: create_civicrm_webform_element
      civicrm_1_contact_1_contact_middle_name: 0
      civicrm_1_contact_1_contact_last_name: create_civicrm_webform_element
      civicrm_1_contact_1_contact_suffix_id: 0
      civicrm_1_contact_1_contact_nick_name: 0
      civicrm_1_contact_1_contact_gender_id: create_civicrm_webform_element
      civicrm_1_contact_1_contact_job_title: 0
      civicrm_1_contact_1_contact_birth_date: 0
      civicrm_1_contact_1_contact_preferred_communication_method: 0
      civicrm_1_contact_1_contact_privacy: 0
      civicrm_1_contact_1_contact_preferred_language: 0
      civicrm_1_contact_1_contact_communication_style_id: 0
      civicrm_1_contact_1_contact_image_url: 0
      civicrm_1_contact_1_contact_contact_id: 0
      civicrm_1_contact_1_contact_user_id: 0
      civicrm_1_contact_1_contact_external_identifier: 0
      civicrm_1_contact_1_contact_source: 0
      civicrm_1_contact_1_contact_cs: 0
      civicrm_1_contact_1_contact_employer_id: 0
      civicrm_1_contact_1_contact_is_deceased: 0
      civicrm_1_contact_1_contact_deceased_date: 0
      contact_1_settings_matching_rule: Unsupervised
      contact_1_number_of_cg35: '0'
      contact_1_number_of_cg22: '0'
      contact_1_number_of_cg23: '0'
      contact_1_number_of_cg24: '0'
      contact_1_number_of_cg25: '0'
      contact_1_number_of_cg26: '0'
      contact_1_number_of_cg29: '0'
      contact_1_number_of_cg32: '0'
      contact_1_number_of_cg51: '0'
      contact_1_number_of_other: '0'
      contact_1_number_of_address: '1'
      civicrm_1_contact_1_address_street_address: 0
      civicrm_1_contact_1_address_street_name: 0
      civicrm_1_contact_1_address_street_number: 0
      civicrm_1_contact_1_address_street_unit: 0
      civicrm_1_contact_1_address_name: 0
      civicrm_1_contact_1_address_supplemental_address_1: 0
      civicrm_1_contact_1_address_supplemental_address_2: 0
      civicrm_1_contact_1_address_supplemental_address_3: 0
      civicrm_1_contact_1_address_city: 0
      civicrm_1_contact_1_address_postal_code: 0
      civicrm_1_contact_1_address_postal_code_suffix: 0
      civicrm_1_contact_1_address_country_id: create_civicrm_webform_element
      civicrm_1_contact_1_address_state_province_id: create_civicrm_webform_element
      civicrm_1_contact_1_address_county_id: 0
      civicrm_1_contact_1_address_location_type_id: '1'
      civicrm_1_contact_1_address_is_primary: '1'
      civicrm_1_contact_1_address_custom_32: 0
      civicrm_1_contact_1_address_custom_33: 0
      civicrm_1_contact_1_address_custom_134: 0
      contact_1_number_of_phone: '0'
      contact_1_number_of_email: '0'
      contact_1_number_of_website: '0'
      contact_1_number_of_im: '0'
      contact_1_number_of_cg15: '0'
      contact_1_number_of_cg17: '0'
      contact_1_number_of_cg6: '0'
      contact_1_number_of_cg31: '0'
      prefix_known: ''
      prefix_unknown: ''
      toggle_message: 0
      message: ''
      activity_number_of_activity: '0'
      participant_reg_type: '0'
      reg_options:
        event_type:
          any: any
        show_past_events: now
        show_future_events: '1'
        show_public_events: all
        title_display: title
        show_full_events: 1
        event_sort_field: start_date
        show_remaining: '0'
        validate: 1
        block_form: 0
        disable_unregister: 0
        allow_url_load: 0
        disable_primary_participant: 0
      civicrm_1_contribution_1_contribution_enable_contribution: '0'
      grant_number_of_grant: '0'
      checksum_text: ''
      create_fieldsets: 1
      confirm_subscription: 1
      block_unknown_users: 0
      create_new_relationship: 0
      disable_contact_paging: 0
      new_contact_source: 'Star Test'
      data:
        contact:
          1:
            contact:
              1:
                contact_type: individual
                contact_sub_type: {  }
                webform_label: 'Contact 1'
            matching_rule: Unsupervised
            number_of_cg35: '0'
            number_of_cg22: '0'
            number_of_cg23: '0'
            number_of_cg24: '0'
            number_of_cg25: '0'
            number_of_cg26: '0'
            number_of_cg29: '0'
            number_of_cg32: '0'
            number_of_cg51: '0'
            number_of_other: '0'
            number_of_address: '1'
            number_of_phone: '0'
            number_of_email: '0'
            number_of_website: '0'
            number_of_im: '0'
            number_of_cg15: '0'
            number_of_cg17: '0'
            number_of_cg6: '0'
            number_of_cg31: '0'
            address:
              1:
                location_type_id: '1'
                is_primary: '1'
        activity:
          number_of_activity: '0'
        grant:
          number_of_grant: '0'
        participant_reg_type: '0'
        reg_options:
          event_type:
            any: any
          show_past_events: now
          show_future_events: '1'
          show_public_events: all
          title_display: title
          show_full_events: 1
          event_sort_field: start_date
          show_remaining: '0'
          validate: 1
          block_form: 0
          disable_unregister: 0
          allow_url_load: 0
          disable_primary_participant: 0
variants: {  }

@MegaphoneJon
Copy link
Contributor Author

@jitendrapurohit Hold for now - someone may have a place where the issue you describe is replicable. I'll report in soon.

@MegaphoneJon
Copy link
Contributor Author

@jitendrapurohit The report I received dealt with a custom module that does Webform exports without implementing the WebformSubmissionExportInterface. So that's not the same as what you're seeing. Could you please give me steps to replicate your scenario? That is, webform submission listings display a pseudoconstant ID and not label.

@jitendrapurohit
Copy link
Collaborator

jitendrapurohit commented Apr 27, 2024

Mine is a simple webform with just Name + Address fields.

Replicating the issues doesn't take any special steps. Just submit the form after applying the PR and check the view results page. The state is rendered as id and not name.

Attached the exported file of the webform here -

webform.webform.test_tokens.yml.txt

Looks like after this PR, webform_civicrm_webform_submission_load() only makes a call to _fillCiviCRMData() which doesn't replace the id of state with names while viewing the submission page.

The following patch works for me (applied on top of this PR)

diff --git a/webform_civicrm.module b/webform_civicrm.module
index 1befb50..e7cc4b4 100644
--- a/webform_civicrm.module
+++ b/webform_civicrm.module
@@ -177,7 +177,12 @@ function webform_civicrm_theme() {
  */
 function webform_civicrm_webform_submission_load($entities) {
   foreach ($entities as $entity) {
-    $data = _fillCiviCRMData($entity->getData(), $entity);
+    $data = $entity->getData();
+    // Replace tokens if we're not editing
+    if (\Drupal::routeMatch()->getRouteName() == 'entity.webform.results_submissions') {
+      $data = _civiTokenReplacement($data, $entity);
+    }
+    $data = _fillCiviCRMData($data, $entity);
     $entity->setData($data);
   }
 }
@@ -285,7 +290,9 @@ function webform_civicrm_webform_submission_view_alter(array &$build, WebformSub
   $webform = $submission->getWebform();
   $config = $webform->getHandlers('webform_civicrm')->getConfiguration();
   if (!empty($config['webform_civicrm']) && !empty($submission->getData()['civicrm']) && \Drupal::currentUser()->hasPermission('access CiviCRM')) {
-    $data = $submission->getData()['civicrm'];
+    $data = _civiTokenReplacement($submission->getData(), $submission);
+    $data = _fillCiviCRMData($data, $submission);
+    $submission->setData($data);
     $links = [];
     $entity_links = [
       'contact' => 'contact/view',

Does this make sense? If yes, perhaps we can merge the 2 functions _fillCiviCRMData() & _civiTokenReplacement() as it was before and conditionally use the token part only when viewing the submission as done in the patch above?

@jitendrapurohit
Copy link
Collaborator

I'll write tests for this.

@MegaphoneJon We already have a test to verify the group labels here - https://github.com/colemanw/webform_civicrm/blob/6.x/tests/src/FunctionalJavascript/GroupsTagsSubmissionTest.php#L155. It might be easy to extend and include state fields too, perhaps?

@MegaphoneJon MegaphoneJon force-pushed the fix-ajax-submission-edits branch 2 times, most recently from 3262ad6 to cf05fe2 Compare April 30, 2024 18:33
@MegaphoneJon
Copy link
Contributor Author

@jitendrapurohit In just incorporated your suggestion, thank you.

I definitely recommend enabling the Hide Whitespace option when reviewing this diff, or it looks much bigger than it is!

@MegaphoneJon MegaphoneJon force-pushed the fix-ajax-submission-edits branch from cf05fe2 to a0370ea Compare April 30, 2024 19:36
@jitendrapurohit
Copy link
Collaborator

Thanks @MegaphoneJon for the update and test.

I've retested this & looks like there are still issues with the display of state field value -

  • While viewing the results page, the state is correctly displayed as name.
  • When i click to view specific submission, the state is displayed as ID.
  • When I star a submission or add a note using AJAX (and reload the page), the state is reverted back to display id (instead of name).

I think we can merge this since it fixes the original star/note issue and can fix the above in a follow up PR with few more tests.

@jitendrapurohit jitendrapurohit merged commit 7b1b1c3 into colemanw:6.x May 4, 2024
4 checks passed
@jitendrapurohit
Copy link
Collaborator

Ah, just confirmed the above id issue is already fixed via #941. After that is merged, i think we're good.

@MegaphoneJon MegaphoneJon deleted the fix-ajax-submission-edits branch May 6, 2024 16:23
@VangelisP
Copy link

VangelisP commented Jul 18, 2024

Apologies for commenting on a merged/closed issue but while debugging my own issue reported here: https://www.drupal.org/project/webform_civicrm/issues/3462311 ,I've stepped over this one which resembles what I am facing:

Upon loading a draft, my values are not numeric anymore, they're becoming strings. This affects so far country_id, state_province_id and all the customfields that are being exposed on the webform and are of type optionvalue (select/radio etc).

@MegaphoneJon
Copy link
Contributor Author

@VangelisP That issue you reported says you're using version 6.2.5, but this PR isn't in a released version yet.

I think #941 is closer to what you're looking for - maybe try applying that (and this?) as a patch?

@VangelisP
Copy link

You are absolutely right! I must have confused that and missed 941. My apologies, I'll leave this issue as-is.
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants