dev/core#6308 FormBuilder - allow tokens and html markup in label, help_pre, help_post and rich content - #35562
Conversation
|
🤖 Thank you for contributing to CiviCRM! ❤️ We will need to test and review this PR. 👷 Introduction for new contributors...
Quick links for reviewers...
|
|
The issue associated with the Pull Request can be viewed at https://lab.civicrm.org/dev/core/-/issues/6308 |
Or could we have one token picker somewhere in a corner of the screen, that could be used for any of the fields that allow tokens? |
label, help_pre, help_post label, help_pre, help_post
|
@colemanw for WYSIWYG editor question - do you think it's reasonable to leave for a separate PR? I appreciate it's a slightly awkward middle ground when markup is supported, but you have to enter it manually. But it feels quite distinct implementation-wise; and I'd rather confirm/get this merged before starting out on the WYSIWYG side. |
|
@ufundo a screenshot would probably be helpful here to understand what we should be seeing when testing this? |
a783e38 to
127d15f
Compare
label, help_pre, help_post label, help_pre, help_post and rich content
127d15f to
61bcae8
Compare
|
@colemanw I've added the wysiwyg editing now. The interplay between angular, @mattwire here's before: no tokens in Rich content blocks; weird bug if you click Cancel rather than Done Screencast.from.2026-05-12.10-02-09.mp4raw html editing in the confirmation message Screencast.from.2026-05-12.10-04-33.mp4no html in help_pre / help_post Screencast.from.2026-05-12.10-03-50.mp4After: Screencast.from.2026-05-12.10-08-17.mp4(fixed the |
b6bba19 to
f24f3ed
Compare
| } | ||
|
|
||
| get afFormCtrl() { | ||
| return angular.element(this.afForm).controller('afForm'); |
There was a problem hiding this comment.
Kindof amazing that this even works, but I'm glad it does!
There was a problem hiding this comment.
Yep.
One day when the af-form is a WebComponent it can just become this.closest('af-form').getTokens() etc. But until then this seems to work pretty well for interfacing / piecewise conversion.
| if (this.closest('af-gui-editor')) { | ||
| const afGuiEditor = angular.element(this.closest('af-gui-editor')).controller('afGuiEditor'); | ||
| return { | ||
| results: afGuiEditor.getTokens(this.hasAttribute('include-submission-tokens')) | ||
| }; | ||
| } | ||
| else { | ||
| throw new Error('civi-rich-text-input[token-picker] doesn\'t know how to get available tokens outside of af-gui-editor context yet'); | ||
| } |
There was a problem hiding this comment.
This coupling is far from ideal as I'm sure you know. But it gets the job done for now.
There was a problem hiding this comment.
Yes...
I think it would probably be better to pass the token list through to the component as a JSON attribute, something like
afGuiField.html:
...
<civi-rich-text-input token-list="{{ $ctrl.getTokensJson() }}" >
...
I was worried this might be inefficient given a) it's a dynamic list based on what fields are currently placed on the form; b) there will likely be multiple civi-rich-text-inputs. But it may still be better to reduce the coupling.
override for special context af-gui-container
6328ca4 to
719a0fe
Compare
|
@colemanw let me know if it helps to break out some of the constituent parts of this PR as it has become a bit of a monster now. I think if breaking it up I would reverse the order:
|
|
@ufundo I think it's fine to merge & iterate on this. Thanks for all your work on it. |
Overview
Adds
<af-markup>and<af-token>elements to which allow for generic rendering of markup with tokens inside an afform -- including markup coming from angular expressions like{{ $ctrl.defn.label }}.Before
After
civi-rich-text-input- similar to CRM.wysiwyg.createCollapsed but usable in angular context; and supports a token pickerTechnical Details
The use of the custom elements may seem a bit roundabout, but it seems to me a good way to handle the joint challenge of rendering html provided by the form admin without rendering any html that a form user might try to sneak in via token values.
It also lends itself nicely to onward development of generic expression evaluation / math; and avoids entrenching angular dependency.
Comments
Having the token pickers on all these fields feels a bit much. It would be good if we could tuck them away somehow.