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

dev/core#5566 Fix clear options not showing for non-admin user #31705

Closed
wants to merge 3 commits into from

Conversation

eileenmcnaughton
Copy link
Contributor

Overview

dev/core#5566 Fix clear options not showing for non-admin user

Before

When a non admin user views a profile with a radio custom field in it with options_per_line set to 2 the clear link is missing. Depending on how the profile is accessed it may also be missing for non-admin users

image

After

image

Technical Details

This is confusing cos replication is hard - in part due to caching & also because viewing profiles in different ways accesses different tpls

  1. the Dynamic tpl - this is at (e.g) https://dmaster.localhost:32353/civicrm/profile/create?gid=1&reset=1
  2. the fields.tpl - this is accessed at (e.g) https://dmaster.localhost:32353/civicrm/admin/uf/group/preview?reset=1&gid=1&fieldId=1

Prior to this change the edit & clear never rendered at all in the former tpl and in the latter tpl the clear was not displayed unless the edit was ALSO displayed. This changes it so they both share a tpl snippet and the clear should always be present

Comments

Copy link

civibot bot commented Jan 3, 2025

🤖 Thank you for contributing to CiviCRM! ❤️ We will need to test and review this PR. 👷

Introduction for new contributors...
  • If this is your first PR, an admin will greenlight automated testing with the command ok to test or add to whitelist.
  • A series of tests will automatically run. You can see the results at the bottom of this page (if there are any problems, it will include a link to see what went wrong).
  • A demo site will be built where anyone can try out a version of CiviCRM that includes your changes.
  • If this process needs to be repeated, an admin will issue the command test this please to rerun tests and build a new demo site.
  • Before this PR can be merged, it needs to be reviewed. Please keep in mind that reviewers are volunteers, and their response time can vary from a few hours to a few weeks depending on their availability and their knowledge of this particular part of CiviCRM.
  • A great way to speed up this process is to "trade reviews" with someone - find an open PR that you feel able to review, and leave a comment like "I'm reviewing this now, could you please review mine?" (include a link to yours). You don't have to wait for a response to get started (and you don't have to stop at one!) the more you review, the faster this process goes for everyone 😄
  • To ensure that you are credited properly in the final release notes, please add yourself to contributor-key.yml
  • For more information about contributing, see CONTRIBUTING.md.
Quick links for reviewers...

➡️ Online demo of this PR 🔗

@civibot civibot bot added the 5.81 label Jan 3, 2025
Copy link

civibot bot commented Jan 3, 2025

The issue associated with the Pull Request can be viewed at https://lab.civicrm.org/dev/core/-/issues/5566

{* Include the edit options list for admins *}
{if $formElement.html|strstr:"crm-option-edit-link"}
{$formElement.html|regex_replace:"@^.*(<a href=.*? class=.crm-option-edit-link.*?</a>)$@":"$1"}
{else}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This else is the actual change - all the rest is just adjusting the 2 templates to share the same code

'n' is not very meaningful. The 'sister' template uses profileFieldName - so let's align
{if $formElement.html|strstr:"crm-option-edit-link"}
{$formElement.html|regex_replace:"@^.*(<a href=.*? class=.crm-option-edit-link.*?</a>)$@":"$1"}
{else}
{$formElement.html}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like it might duplicate things? I don't see this in the fields.tpl nor in dynamic.tpl previously

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or is this just the wrench?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@seamuslee001 yeah so what was happening is that because the radio options were not being laid out as desired the tpl was iterating through & rendering the options html not the radio group html - and then using that to re-add some of the radio group html (but was dropping the clear when the edit was not in play)

Although this PR does mostly get us there I wound up concluding there is a better approach - ie update the renderer to add the classes - see #31706 (as of writing the PR name is not a good description of what it does)

…alues

This does the same as civicrm/civicrm-packages#416
but in Civi code rather than in packages.

My take on it is that the original sin is that the quickform class for rendering
radio options does not nest them in a div / allow us to add classes to that div
and hence we are working around it by rendering the radio options
individually in the template layer.

If we fix that maybe we revert this - it is mostly a case of
registering a class with more suitable markup in
HTML_QuickForm::registerElementType()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants