You are here

function itoggle_views_handler_field::render in iToggle 7

Same name and namespace in other branches
  1. 7.2 modules/views/itoggle_views_handler_field.inc \itoggle_views_handler_field::render()

Render the trigger field and its linked popup information.

Overrides views_handler_field::render

File

modules/views/itoggle_views_handler.inc, line 50
View handler for iToggle Views

Class

itoggle_views_handler_field
A handler to provide a custom field

Code

function render($values) {
  $type = $this->_itoggle['type'];
  $property = $this->_itoggle['property'];
  $id = $this->_itoggle['info'][$type]['entity keys']['id'];
  if (isset($values->{$id})) {
    $id = $values->{$id};
    $entity = current(entity_load($type, array(
      $id,
    )));

    // @TODO check if value exists in $values array
    $checked = $entity->{$property} == 1;
    return theme('itoggle', array(
      'type' => $type,
      'id' => $id,
      'property' => $property,
      'checked' => $checked,
      'scope' => 'entity',
    ));
  }
  return NULL;
}