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

CATL-1564: Handle hidden (select) fields in submissions and emails #335

Conversation

nishant-bhorodia
Copy link
Contributor

Overview

If the widget type for a civicrm select options is changed to hidden, then when viewing the submissions, it starts to show as IDs instead of labels.
For example, if the country field's widget type is changed to hidden then in submissions instead of showing the country name (In our case, United Kingdom), it will start to show ids (in our case, 1226).

D7 or D8?

This PR is for D7

Before

Submission
screenshot(8)

Email
screenshot(10)

After

Submission
screenshot(9)

Email
screenshot(11)

Technical Details

  1. Handling of hidden fields, in terms of submission/email rendering, is like textfields. Meaning, whatever value they have, it is rendered as it is in submissions or emails send by webform.
  2. But in our case we are making it possible to hide select fields which as a result, started showing ids instead of labels since the structure for select list and hidden fields is different.
  3. To fix this, used function webform_civicrm_webform_submission_render_alter(&$renderable).
  4. To check if the rendered field was select or not (before making it hidden), we are using wf_crm_field_options which returns options if the field has any (for select fields).
  5. After detecting if the field was a select field, we are processing the field values and changing them to labels.

Comments

@nishant-bhorodia nishant-bhorodia changed the title [WIP: Please don't review or merge yet] CATL-1564: Handle hidden (select) fields in submissions and emails CATL-1564: Handle hidden (select) fields in submissions and emails Aug 6, 2020
@nishant-bhorodia
Copy link
Contributor Author

Hey @KarinG @colemanw ,
This passed testing on our end, please can you review?
thanks!!

@KarinG
Copy link
Collaborator

KarinG commented Aug 6, 2020

Hi @nishant-bhorodia - please see: my comment re: D8 here:
#337 (comment)

webform_civicrm.module Outdated Show resolved Hide resolved
@nishant-bhorodia nishant-bhorodia force-pushed the CATL-1564-case-tags-value-hidden-field branch from 19664b1 to 8e18335 Compare August 24, 2020 06:09
@colemanw colemanw merged commit e00b307 into colemanw:7.x-5.x Aug 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants