Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 295743

Add a 'machine_name' widget for string field types with a UniqueField constraint

$
0
0

Problem/Motivation

Please guide me what changes I need to do for make machine name working for content entity.

Currently in Drupal 8, a 'machine_name' widget is available only on primary identifiers of config entities, as content entities were expected to use serial entity identifiers only.

Some specific content entity types, however, are bordering to configuration and are therefore better identified by a string. Use cases include Core's new Workspace, Entityqueue's EntitySubqueue, FillPDF's FillPDF forms and the OP's contrib PET entity types.

This constitutes a regression from D7 where 'machine_name' fields were available as entity identifiers.

Proposed resolution

  1. Create a machine_name widget
  2. Allow 'string' type primary identifiers to specify the 'machine_name' widget in a content entity type's BaseFieldDefinition.
  3. Switch Core's Workspace entity to using a 'machine_name' widget on its 'string'-type id field replacing the current, ugly workaround.

Remaining tasks

User interface changes

- none -

API changes

- none -

Data model changes

- none -

Original issue

I'm trying to port PET module, it uses custom entity to manage mail templates.
It has a machine name field, which I'm not able to make in Drupal 8. I checked code of Drupal 8 core, it uses machine name field for config type entities only, I did same way but it does not behave like machine name.

Please guide me what changes I need to do for make machine name working for content entity. Also let me know if this is an issue in core, I think the way fields are rendered in content entity might be the reason.

Current code can be seen here http://cgit.drupalcode.org/pet/tree/.


Viewing all articles
Browse latest Browse all 295743


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>