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.
This could just be a documentation issue but here's my issue:
I have some fields that have sub parameters. Examples are Date and Currency fields. Right now there isn't a good way to call this. Calling the getCustomField() method (for field field_custom_field) is clunky and it's also possible that it doesn't return all the property callbacks. So for Currency for example calling the "amount_decimal" property is not possible without going down to the EntityFieldWrapper.
Is there any plans or method of doing this?
Comments
Comment #2
zengenuity CreditAttribution: zengenuity at Zengenuity commentedThe need for a date field template is in #2364489: Include date format options for date type fields. For currency, is that a commerce_price type field? If so, we can add templates for that type too which will handle the subproperties in a reasonable way. Take a look at entityreference and image field templates for examples of how to add additional method templates for specific types of fields if you want to take a stab at it.
Comment #3
Derimagia CreditAttribution: Derimagia at Mindgrub Technologies commentedThe templates are nice for syntactic sugar, but I'm not sure that's the right approach since we want something that works on all fields. All of the info is in the EntityMetadataWrapper so it should be able to be got at. I'll take a look at the generator to see what can be done.
After we have this structure down, we can then add the templates on top of that but devs will have a backup option so they don't need to fallback to EnittyMetadataWrapper to get what they want.
Comment #4
zengenuity CreditAttribution: zengenuity at Zengenuity commentedHmm...maybe an optional subproperty parameter on
WdEntityWrapper::get()
.