-
-
Notifications
You must be signed in to change notification settings - Fork 828
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
Add support for custom css class names for afform containers. #32270
base: master
Are you sure you want to change the base?
Conversation
🤖 Thank you for contributing to CiviCRM! ❤️ We will need to test and review this PR. 👷 Introduction for new contributors...
Quick links for reviewers...
|
@twomice what's the purpose of the prefixing? |
Short story: It's the only way Allen could figure out to make it work at all. Longer story: It's a kind of namespacing, I guess. AF is already storing its own If we were just adding class names it wouldn't matter, but we also have to "read only our class names" (for display in the field) and also sometimes "remove only our class names" (when, say, the field is cleared). So, yeah, the prefixing is my "novice first-time afform hack" solution for the fact that |
@twomice ok that makes sense. I think we could make a whitelist of the formbuilder-controlled classes and filter those out of the equation. |
@colemanw Yes, that would be somewhat better. But also this: On Kurund's PR, there's already discussion of NOT allowing free-form text entry for class names, and instead using an optionValue list. I think that approach would also help solve this "namespacing" issue in this PR (along with equivalent usability problems mentioned in that discussion). |
Overview
Add support for adding custom class names (html 'class' attribute) to afform containers.
Similar to #32266 (which does the same for afform fields).
Ref: https://lab.civicrm.org/dev/core/-/issues/4571
Before
No way to add custom class names for containers in afform UI.
After
Now you can.
Technical Details
Unlike fields, containers are already using the 'class' attribute for special
af-*
-prefixed classes such as 'af-layout-rows' etc.af-container-class-
, while only displaying the 'un-prefixed class name' in the UI.my-class
:my-class
appears in the UI.af-container-class-my-class
.div.af-container.my-class
, when in fact the correct selector would bediv.af-container.af-container-class-my-class
.Comments
I'm sure there's a more elegant way to do this, even if we accept the downside mentioned above.