FieldSpec - Generate better default field titles for DAOs #25080
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
Improves autogenerated field titles, beneficial for some extensions.
Before
Fields with
id
oris
in their name don't get a default title; confusing code comment incorrectly asserts that they shouldn't have one.After
Every field gets a title.
Technical Details
I stumbled across this when adding metadata to CiviDiscount. Normally when you generate a DAO from the xml, any field without a
<title>
will get an autogenerated one based splitting and uc_words-ing the<name>
. However, I noticed that some fields were getting autogenerated titles and others weren't... I finally traced it to this function that boldly (but incorrectly) asserts "id's do not get titles". That's not true; every field in the core schema has a title, in fact after making this change and regenerating all core DAOs... nothing changed. So apparently after making a function to deliberately not make titles for those fields, we then spent years diligently working around it by manually adding<title>
to every field!So even though this has no apparent impact on core, it's good to have anyway and now fields in Extensions will consistently have titles. With this change I re-ran
civix generate:entity-boilerplate
for CiviDiscount and was rewarded with this: https://lab.civicrm.org/extensions/cividiscount/-/merge_requests/282/diffs