You are here

class button_field_handler_field in Button Field 8

Same name and namespace in other branches
  1. 7 includes/views/handlers/button_field_handler_field.inc \button_field_handler_field

Button field views handler

Hierarchy

Expanded class hierarchy of button_field_handler_field

1 string reference to 'button_field_handler_field'
button_field_field_views_data in includes/views/button_field.views.inc
Implements hook_field_views_data().

File

includes/views/handlers/button_field_handler_field.inc, line 10
Views field handler for button fields.

View source
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,
      ),
    );
  }

}

Members

Namesort descending Modifiers Type Description Overrides
button_field_handler_field::set_items function Return an array of items for the field.