You are here

function content_type_groups_entity_presave in Content type groups 7.2

Implements hook_entity_presave().

File

./content_type_groups.controller.inc, line 262
Contains controllers and entity hooks for the content_type_group entity.

Code

function content_type_groups_entity_presave($entity, $entity_type) {
  if ($entity_type == CONTENT_TYPE_GROUPS_ENTITY_NAME) {

    // The form submits all checkboxes with unchecked ones having a value of 0. We need
    // to remove those and only keep the ones that were checked for saving in the database.
    foreach ($entity->content_types as $content_type => $checked) {
      if (!$checked) {
        unset($entity->content_types[$content_type]);
      }
    }
  }
}