Closed (fixed)
Project:
Drupal core
Version:
8.0.x-dev
Component:
field system
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
3 Jan 2012 at 21:12 UTC
Updated:
28 Jun 2022 at 10:16 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
solotandem commentedAttached patches implement the proposed resolution for Drupal 8 and 7.
Comment #3
joachim commented> If there is some use case or justification for the "field_" prefix on fields created through the UI, please let me know.
My assumption (and it's only that) is that this guarantees against clashing with any fields that are defined by modules.
Also, it means you can easy tell which ones are user-created.
Comment #4
boombatower commentedYes, that was my guess to. Our use-case is that people create fields in UI and export using features and such to become "coded" fields and given that the field length is restricted in length field_ is rather wasteful.
Patches are backwards (d7 = d8, etc).
Comment #5
solotandem commentedOops. I named the patch files opposite their core versions.
Comment #7
barry_fisher commentedAs a sidenote, I've created a D7 module that removes the
field_prefix from being added in the Field UI. Basically it overrides the validate functionality and alters the field ui overview form accordingly. May be useful to anyone landing on this post as I did and needed a quick fix workaround.http://drupal.org/project/field_name_prefix_remove
Comment #8
swentel commentedSo how about we make this configurable with our shiny new configuration system in core ?
No UI to configure this, but it's easy to move this into staging, change it and then import - or use 'drush cedit field_ui.settings' to change to what you like.
Comment #9
aspilicious commentedI like it, but we need a test to verify changing a prefix actually works :)
Comment #10
swentel commentedI guess yeah, here it is :)
Comment #11
aspilicious commentedYihaa!
Comment #12
alexpottHmmm... I'm not sure about this change basically because changing this after you create a field will totally break your site. Either fields created by the field ui have field_ not... but making this configurable seems open cans of worms. Personally I think all field names should be namespaced by the module that creates them... so actually I'm arguing that we want
field_Comment #13
aspilicious commentedWhy would that break existing fields?
Comment #14
stijndm commentedGreat stuff. Good idea to have it as a hidden setting.
@alexpott I'm not sure how this will break existing fields as this settings is only used when a new field is created.
As for the namespacing issue, I feel there is enough argument to make this configurable. People working on distributions or features might want to namespace their fields according to the content type or feature they are building. Having field_ automatically prefixed eats into the character limit making it more difficult to have proper field naming, sometimes resulting in the use of arbitrary and meaningless abbreviations.
The average Drupal user/configurator will never know of the existence of this setting keeping all their fields namespaced within the field module. While power users have some extra flexibility.
Comment #15
swentel commented@alexpott This won't break existing fields in any way. This is just the prefix when you are creating a new field, after that nothing can go wrong anymore.
I've talked this through with yched at DrupalCon and he was ok with it, also since it's a hidden setting. We'll document it of course, but there will be no UI in core that allows you to change this. This is a power user configuration option, which people have been wanting for a while already anyway.
Setting to RTBC for now.
Comment #16
swentel commentedNeeded a reroll.
Comment #17
alexpottThis looks weird... does the field_prefix variable exist in Drupal 7? Perhaps you want to use
update_7_to_8_install_default_config()?Comment #18
swentel commentedAh, no it doesn't exist, good to know :)
Comment #19
swentel commentedChanged the update function.
Comment #20
aspilicious commentedOk another try :). Thnx alex!
Comment #21
alexpottCommitted 097303e and pushed to 8.x. Thanks!
Comment #22
tstoecklerCan we add a little snippet to default.settings.php that informs people about this? I'm not entirely sure if we're 100% consistent with that currently but I do think it is a common pattern to do this, and one I think makes sense.
If someone disagrees or in general thinks this should be a separate issue, no problem, I just thought this is pretty unproblematic.
Comment #23
swentel commentedMakes sense to me.
Comment #24
alexpottThis should have the default value to be consistent with the other sections...
Also I'm not sure this is really required as in reality we should be encouraging people to change this in their config... if we want to only manage this here then it should move out of CMI into Settings.
Comment #25
tstoecklerRe #24: That's true, but the question then is, how will people know about this at all? I don't think when people will someday download Drupal 8.0 that they will open up every single config file to see what they can configure.
Comment #26
swentel commentedWe could create a change notice I guess ? That's fine for me as well. This is not settings indeed.
Maybe we can include this in the tour integration for Field UI ? #1960824: Write tour integration for Field UI module
Comment #27
swentel commentedCreated a change notice, that's good enough for me imo.
See https://drupal.org/node/2060489
Comment #29
solotandem commentedFor those that want to see this back ported to D7, attached is a rerolled patch that works with recent releases of D7, including 7.28.
Not changing the version; if there is traction to back port, then this can be done or a new issue created and referenced here.
Comment #30
dstorozhukHello, that is weird, but settings the
$conf['field_ui.settings']['field_prefix'] = 'f_';doesn't make any effect.I also tried to change the 'field_prefix' in
path/to/my/sync/field_ui.settings.ymland still have no luck.Does somebody has the same issue.
PS. other settings could be controlled fine from settings.php or changing configs in
path/to/my/sync/.Comment #31
markconroy commented@dstorozhuk (sorry, I know you probably have this fixed by now, but just for others who come here)
You need to use
$config['field_ui.settings']['field_prefix'] = 'f_'not
$conf['field_ui.settings']['field_prefix'] = 'f_'.