Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
There are limited examples of how to work with entity fields.
In the context of core Drupal 7, this is an attempt to give more complete attention to:
1. Defining & Creating fields
2. Attaching them to an existing entity. in other words, defining and creating field instances.
3. Change their implementation in form & view contexts as part of different flows.
Test cases:
1. Usage in the user_profile_form vs user_registration form. I believe this is a reasonable contrast in which to demonstrate the expansion of an existing entity with fields.
Comments
Comment #1
Mile23There are two examples which create fields: field_example and field_permission_example.
There is an example of attaching fields to an entity in node_example. You can see it happen here: http://cgit.drupalcode.org/examples/tree/node_example/node_example.modul... Nodes (and users) are just another form of entity.
I'm not sure what you mean about 'flows.' In Field API you define widgets and formatters; you could define as many formatters for a field type as you wish, and then use different formatters for different display modes (such as Full vs. Teaser). This is demonstrated in both of the field examples... In field_example we present the same data with different widgets and formatters. In field_permission_example, we add a formatter for the existing text field.
As for the two user forms, that would be interesting to demo. Do you have a patch?
Comment #2
Mile23Oops... Double post.
Comment #3
Mile23Comment #4
Mile23Generally unassigning issues. Please re-assign yourself as desired.
Comment #5
jungleNo activity for over 6 years. I am closing this. Please feel free to reopen if necessary.
Thanks!