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 custom field type Hidden #27235
Add custom field type Hidden #27235
Conversation
🤖 Thank you for contributing to CiviCRM! ❤️ We will need to test and review this PR. 👷 Introduction for new contributors...
Quick links for reviewers...
|
Comparing to the TrackingFields, I think users will have the reasonable expectation that a hidden custom field won't show up in a emails, but I think with this all the message templates that add all custom fields are going to include these hidden fields. So if you have a hidden field for tracking where donors clicked, that's going to be sent to donors in their contribution receipt. |
I like this - but I think we need to spec this out a bit before committing to an approach. I think the appropriate replacement for tracking fields isn't a "hidden" custom field type, but an "is hidden" checkbox on the profile field configuration. "Hidden" IMO should be an HTML type, not a data type. This allows us to maintain strict data typing in API4, and overall seems more likely to play well with other code. Do hidden fields appear in SK? I'd lean yes. Should they be editable? I suppose so. But maybe Eileen's |
Also pinging @twomice since CRM-20922 suggests he has an interest |
@MegaphoneJon I've expanded the PR description to clarify that this does add a new |
OK, I accidentally got some real-world testing on this because I forgot this is part of the Megaphone Civi flavor. Hidden fields work as expected in profiles. Yay! In SearchKit, attempting to use these in the I think there's also some interaction here between the former HTML type and the current one. In the examples above, the field has an |
@MegaphoneJon thanks for the feedback. I've updated the PR and I think it addresses everything you noted. |
switch ($customFieldBAO->data_type) { | ||
case "String": | ||
case "Int": | ||
case "Float": | ||
case "Money": | ||
// if Multi Select field is selected in custom field | ||
if ($customFieldBAO->html_type == 'Text') { | ||
$action -= CRM_Core_Action::BROWSE; | ||
} | ||
break; | ||
|
||
case "ContactReference": | ||
case "Memo": | ||
case "Date": | ||
case "Boolean": | ||
case "StateProvince": | ||
case "Country": | ||
case "File": | ||
case "Link": | ||
$action -= CRM_Core_Action::BROWSE; | ||
break; | ||
// Remove link to edit option group if there isn't one | ||
if (!$customFieldBAO->option_group_id) { | ||
$action -= CRM_Core_Action::BROWSE; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This absolutely takes the prize for the most bizarre waste of 20 lines I've ever seen.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉 🎉 Why I'm awarding this one top prize 🏆 🥇 🏆
- Switch statement: why even... dear god why?
- The code comment made absolutely no sense.
- The rest of the switch statement: LOL
- None of it had anything to do with the actual criteria that needed to be checked
Further feedback from user testing:
But also that overall the last round of changes were all successfully tested. |
I wouldn't expect a hidden field to be editable. I imagine if we changed it to type text then we'd get bug reports that (IMO correctly) complain that hidden fields should be of type hidden not text.
That does sound like a bug. I'll check... |
@MegaphoneJon sorry I'm unable to reproduce the 2nd bug you mentioned. When I create a new hidden custom field and enter some data (via the API since you can't do it in the UI) I'm able to see it both in the UI and in SearchKit: However, if the field was created prior to that last bugfix (the one that took the prize) then you should check |
Overview
Adds a "hidden" custom field type which can collect data on forms without being seen (e.g. by storing a value from the url or set by javascript)
Technical Details