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.
The issue queue has lots of requests for custom handlers for custom entity properties:
#2090621: Ubercart Fields Integration
#2044197: Editable Taxonomy term title and description
#2036315: Commerce Product Entity support
#2017973: Add ability to edit path aliases
These are all going to look pretty similar. What I think we can do instead is create a generic handler, and use Entity API's metadata system to a) find properties that can be expose, and b) handle saving those properties.
Comment | File | Size | Author |
---|---|---|---|
#4 | 2090731.editableviews.metadata-property-handler.patch | 23.9 KB | joachim |
Comments
Comment #1
hanoiiI am about to work on the ubercart fields integration as I kind of need it, not sure if I'll do it custom or trying to improve this module.
Either way I am not that familiar with the Entity API's metadata system, so if you are, I wonder if you can share your ideas on how this might work and I can see if I can try to work it out that way.
Thanks.
Comment #2
joachim CreditAttribution: joachim commentedThe entity metadata defines properties on entities. For all properties there is a 'getter callback'. Some also have a 'setter callback'. Each property also has a type defined.
I was thinking that all the properties that have a 'setter callback' and have a type that we can feasibly hope to create a sane form element for, AND which are not already FieldAPI fields, could share a common handler.
Comment #3
AnybodyThis feature request becomes more and more important. A solution would be very very helpful for many modules and installation profiles.
Comment #4
joachim CreditAttribution: joachim commentedThis came up in a client project, so I've implemented it.
Here's the patch (though our tests are failing at the moment due to dependencies not being declared to the testbot... they pass locally!)
Comment #6
joachim CreditAttribution: joachim commentedComment #8
kopeboy CreditAttribution: kopeboy commentedcould you release a new beta for this? I think is quite important :)
Thank you very much for the module!
Comment #9
joachim CreditAttribution: joachim commentedI already did - beta 8. You can see it in the release notes: https://drupal.org/node/2244543.
You're welcome :)
Comment #11
joachim CreditAttribution: joachim commentedTestbot being weird...
Comment #12
ledom CreditAttribution: ledom commentedMay be a mention into readme or documentation on how to access ubercart fields ("enter entity or editable into searchbox") and others would be good.
Thanks a lot for your work, this was a big lack.
Comment #13
joachim CreditAttribution: joachim commentedGood idea. Care to file a new issue for that and make a patch for the README? You can also add something to the documentation page: https://www.drupal.org/node/1943662
Comment #14
ledom CreditAttribution: ledom commentedThanks, will do that
Question, what about product stock level?
Unable to find this field into entity metadata. Is there a workaround?
Comment #15
joachim CreditAttribution: joachim commentedYou can either write a patch for Commerce stock so that the stock level has an Entity API metadata setter callback, or write an editable views handler for it. The first option is definitely preferable, as it adds something that's usable in a wider context.
Comment #17
jkhanlar CreditAttribution: jkhanlar commentedI enabled versions 7.x-1.0-beta9 and 7.x-1.x-dev of this module to see if adding editable ubercart fields to a view was possible, and it seems that it is not. How can I add editable fields for ubercart fields/attributes in a view?
Comment #19
joachim CreditAttribution: joachim commentedPlease don't reopen old fixed issues. See comment #15 regarding further support for ubercart, and indeed any other entity type.
Comment #21
devad CreditAttribution: devad commentedIt took me a bit to find editable Taxonomy term name and description fields.
So, i'm just posting a tip here to help others.
Editable Taxonomy term name and description field are available as:
Taxonomy term: Entity metadata property (editable)
Add one such field with Metadata property: Name
And second one with Metadata property: Description
Thanx for great work!
Comment #22
Dr.Osd CreditAttribution: Dr.Osd commentedI use latest dev version but have no way to access for commerce product title in editable views. How can I add to my view Commerce product Title (editable)??
Comment #23
joachim CreditAttribution: joachim commentedDoes it maybe not have a setter callback?
Comment #24
Dr.Osd CreditAttribution: Dr.Osd commentedMaybe. I use module as is without additional settings. Do you have some documentation about setter callback?