0

I'm playing with Entity Construction Kit (ECK) on a Drupal 7 site. In a custom module I need to add, update and get ECK record.

By admin panel I created my entity "company" and his bundle "company". In my module I already built add and get method for the entity record (methods are working).

But how can I update a specific record ?

Thanks.

2
  • Are you talking about services or web enviroment?
    – vgoradiya
    Commented Aug 11, 2015 at 10:25
  • I'm not sure to understand your comment... but I'm in a custom module so it's the web environment of Drupal.
    – Promo
    Commented Aug 11, 2015 at 10:51

1 Answer 1

1

After thousands of research, according to the page Creating and Modifying Entities this is the way to update an entity :

$entity = entity_load_single('entity_name', $entity_id);
$entity->title = 'new name';
$entity->save();

This will load the entity 'entity_name' with the id 'entity_id', then the title will be replace by 'new name'.

I hope its help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.