Search code examples
phpdrupal-7

Store entity in checkbox


Sorry for asking such a question, Do we have any way to store Entities to Checkboxes ? Because I'm doing a "Tableselect", I want to multi check and I get by each check value is an Entity.

Ex: I want select 5 rows then I have to delete 5 rows that I have selected, delete function have to run via delete entity API:

  • Old way, get list Id select, make an SQL query then execute the query.
  • New way: Get list Entity, delete data by delete API <--- That is what I want to know, do we have this way ?

Solution

  • I have got the answer after few minutes....quite easy, just use entity_load

    $results = <List ID checkbox>;
    foreach ($results as $var) {
         $entity = entity_load('entity_example_basic', array ($var));
     // Do sth....
    }