Several webform elements support multiple values and the formatting/presentation code for these elements needs to be reusable and maintainable.

Goal

Provide a simple mechanism to output an element's submission value(s).

Notes

  • Most elements just need to some very basic formatting. For example, emails and URL should be linked.
  • Need to support HTML and plain text formatting.
  • Supporting plain text is very important for exporting data.
  • Trying to avoid having every submission passed through Drupal theme layer. This would be a major performance hit but might be unavoidable.
  • Support multiple values will make it easier for a webform submission to be posted to the Field API.

Tasks

  • Refactor OptionsBase to support multiple values.
  • Rework formatHtml() and formatText() to route to values or single value.
  • Add protected formatHtmlMultiple() and formatTextMultiple().
  • Add protected formatHtmlValue() and formatValue().
  • Split #format into #format_value and #format_multiple.
  • Write update hook to update #format in webforms and admin settings.
  • Move OptionsBase code WebformElementBase
  • Refactor tokens to support format_value and format_multiple. [webform_submission:values:subject:format_value:format_multiple]
  • Update tests.

#format_value

  • raw
  • value
  • link
  • etc...

#format_values

  • Comma
  • Semicolon
  • And
  • Ordered list
  • Unorder list
  • Custom

Multiple Elements (#multiple)

  • Checkboxes
  • Select
  • TableSelect
  • Toggles
  • EntityAutocomplete (#tags)
  • ManagedFile
CommentFileSizeAuthor
#8 refactor_and_rework-2845028-8.patch241.51 KBjrockowitz

Comments

jrockowitz created an issue. See original summary.

jrockowitz’s picture

  • jrockowitz committed a04cedc on 2845028-refactor-multiple
    Issue #2845028: Refactor and rework element formatting to better support...

  • jrockowitz committed ae3490b on 2845028-refactor-multiple
    Issue #2845028: Refactor and rework element formatting to better support...

  • jrockowitz committed 9dd0034 on 2845028-refactor-multiple
    Issue #2845028: Refactor and rework element formatting to better support...

  • jrockowitz committed cc2d5f4 on 2845028-refactor-multiple
    Issue #2845028: Refactor and rework element formatting to better support...

  • jrockowitz committed 647525a on 2845028-refactor-multiple
    Issue #2845028: Refactor and rework element formatting to better support...
jrockowitz’s picture

Status: Active » Needs review
StatusFileSize
new241.51 KB

  • jrockowitz committed 257da5c on 8.x-5.x
    Issue #2845028 by jrockowitz: Refactor and rework element formatting to...
jrockowitz’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.