-
-
Notifications
You must be signed in to change notification settings - Fork 824
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 pseudoconstant to UFField dao #14041
Conversation
(Standard links)
|
@totten @colemanw @seamuslee001 I just want to take a minute to think about this. We have a lot of precedent for linking id fields via pseudoconstants - generally to name fields on other tables. This is a new pattern in that it links a text field to a title field coming from a function. I suspect there could be field titles that are the same for different fields - although there is a reasonable case to say that should just be fixed (perhaps easier in theory than practice I'm not sure) I can't think of a problem per se but I know @colemanw elsewhere is trying to look at pseudoconstant nuance & I just wanted to check if we are starting a new protocol here & if so if there is any reason to hesitate
|
Hi @eileenmcnaughton. No I don't think this is starting a new standard or deviating from what we already do. There are many places where we use a callback to list options that are not an FK to another field:
Also to clarify, this function returns machine name keys and that's what's used to validate the value, not the title which may be translated. And just to reiterate, this is the exact function used to validate the passed-in value. E.g. it already won't accept anything other than what's in this list. |
@colemanw ok |
Overview
When adding a UFField to a profile, the fieldname passes through a validation function which checks all available fields. I'm using that same function as a pseudoconstant provider so the api can expose the option list and provide the same validation.
Before
Field appears as a textfield in api explorer.
After
Notes
Also fixes a
fixme
by usingCivi::$statics
instead of a local static var.