button_field_handler_field.inc in Button Field 7
Same filename and directory in other branches
Views field handler for button fields.
File
includes/views/handlers/button_field_handler_field.incView source
<?php
/**
* @file
* Views field handler for button fields.
*/
/**
* Button field views handler
*/
class button_field_handler_field extends views_handler_field_field {
/**
* Return an array of items for the field.
*/
function set_items($values, $row_id) {
$display = array(
'type' => $this->options['type'],
'settings' => $this->options['settings'],
'label' => 'hidden',
// Pass the View object in the display so that fields can act on it.
'views_view' => $this->view,
'views_field' => $this,
'views_row_id' => $row_id,
);
// Get the entity and type that we will render the field about.
$entity_type = $values->_field_data[$this->field_alias]['entity_type'];
$entity = $this
->get_value($values, 'entity');
if (!$entity) {
return array();
}
$langcode = $this
->field_language($entity_type, $entity);
$render_array = field_view_field($entity_type, $entity, $this->definition['field_name'], $display, $langcode);
// Check to see if we should return the field already rendered.
if ($this->options['field_api_classes']) {
// Make a copy.
$array = $render_array;
return array(
array(
'rendered' => drupal_render($render_array),
),
);
}
return array(
array(
'rendered' => $render_array,
),
);
}
}
Classes
Name | Description |
---|---|
button_field_handler_field | Button field views handler |