titobrasolin / Drupal7.Services

.NET API to integrate with Drupal 7 via Services 3 module.
MIT License
7 stars 3 forks source link

How to add/update Field Collection ? #17

Closed shafiqhossain closed 7 years ago

shafiqhossain commented 8 years ago

A field collection is created in Drupal site and the dump is seen as follows:

    field_fields_field_collection : [XmlRpcStruct]: hashcode { 61027830 }
    {
        und : [XmlRpcStruct[]]: hashcode { 12379565 }
        {
            [XmlRpcStruct]: hashcode { 44307222 }
            {
                value : 3
                revision_id : 3
            }
            [XmlRpcStruct]: hashcode { 63220684 }
            {
                value : 4
                revision_id : 4
            }
        }
    }

How we can add/update the fields in field collection and retrieve field collection entity ?

thanks

titobrasolin commented 8 years ago

I would use the Services Entity API module: https://www.drupal.org/project/services_entity It creates an "entity_field_collection_item" resource with CRUD operations.

By the way, I agree with this comment: https://www.drupal.org/node/2196685#comment-10285879

You can certainly code services to pull the field collection details, but that's not how Drupal services module works. Services expects every entity to be it's own request. If you'd like services to be a bit more efficient by combining end points ahead of time, it can be done, but it requires either views and services views or a fair amount of custom code.

titobrasolin commented 7 years ago

Hi @shafiqhossain I'm closing this issue now but I also created a wiki page with a short example: https://github.com/titobrasolin/Drupal7.Services/wiki/How-to-create-a-new-node-with-a-field-collection-field-in-it