Could support Remove field name prefix module?

Created on 7 September 2018, over 6 years ago
Updated 10 April 2023, over 1 year ago

Could support Remove field name prefix module ( https://www.drupal.org/project/field_name_prefix_remove β†’ ) ?
I use the module to remove 'field_'.
In the file: src\Form\CorrespondingReferenceForm.php
delete the checks:

  • Line 175~177
  • Line 208~210
        if (!preg_match('/^field_.*$/', $fieldName)) {
          continue;
        }

and others check that I don't find.

✨ Feature request
Status

Needs work

Version

5.0

Component

Code

Created by

πŸ‡ΉπŸ‡ΌTaiwan agrozyme

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States Chris Burge

    I fully agree that we should get the field prefix from the field_ui.settings config rather than assume it is field_,

    The field prefix can change, though. If we use the field prefix today, that may exclude fields created with an old prefix. The only time the field prefix is used is for field creation.

    In the CorrespondingReferenceForm class, both ->getFieldOptions() and ->getBundleOptions() call getReferenceFieldMap() to populate their respective foreach loops.

      /**
       * Gets a map of possible reference fields.
       *
       * @return array
       *   The reference field map.
       */
      protected function getReferenceFieldMap() {
        $map = $this->fieldManager->getFieldMapByFieldType('entity_reference');
    
        return $map;
      }
    

    $this->fieldManager->getFieldMapByFieldType only returns fields of type 'entity_reference'. Isn't that exactly what we need to begin with? If that's the case, then patch #4 fits the bill.

  • πŸ‡ΊπŸ‡ΈUnited States Chris Burge

    I see what you mean about wanting to only return fields defined in config now:

    #13 has the code to get that list. There may be valid cases for using CER with fields defined programmatically. What do you think about making the behavior configurable (behind a toggle)?

    E.g.:
    Which fields should be available for corresponding entity references?
    O Fields defined in configuration (default)
    O All fields

Production build 0.71.5 2024