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

FieldSpec - Generate better default field titles for DAOs #25080

Merged
merged 1 commit into from
Nov 29, 2022

Conversation

colemanw
Copy link
Member

@colemanw colemanw commented Nov 29, 2022

Overview

Improves autogenerated field titles, beneficial for some extensions.

Before

Fields with id or is 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

@civibot
Copy link

civibot bot commented Nov 29, 2022

(Standard links)

@civibot civibot bot added the master label Nov 29, 2022
@eileenmcnaughton
Copy link
Contributor

Unrelated fails

@eileenmcnaughton eileenmcnaughton merged commit c265546 into civicrm:master Nov 29, 2022
@eileenmcnaughton eileenmcnaughton deleted the titleSpec branch November 29, 2022 21:07
MegaphoneJon pushed a commit to MegaphoneJon/org.civicrm.module.cividiscount that referenced this pull request Nov 28, 2023
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