Commit 7a0b6745 authored by alexpott's avatar alexpott

Issue #2137305 by dawehner: Fieldapi fields have empty values in a view REST export (using JSON).

parent 77d0c143
......@@ -143,9 +143,9 @@ public function render($row) {
if (($field->field_alias != 'unknown') && !empty($this->rawOutputOptions[$id])) {
$value = $field->sanitizeValue($field->getValue($row), 'xss_admin');
}
// Otherwise, pass this through the field render() method.
// Otherwise, pass this through the field advancedRender() method.
else {
$value = $field->render($row);
$value = $field->advancedRender($row);
}
$output[$this->getFieldKeyAlias($id)] = $value;
......
......@@ -25,14 +25,14 @@ class StyleSerializerTest extends PluginTestBase {
*
* @var array
*/
public static $modules = array('views_ui', 'entity_test', 'hal', 'rest_test_views');
public static $modules = array('views_ui', 'entity_test', 'hal', 'rest_test_views', 'node', 'text', 'field');
/**
* Views used by this test.
*
* @var array
*/
public static $testViews = array('test_serializer_display_field', 'test_serializer_display_entity');
public static $testViews = array('test_serializer_display_field', 'test_serializer_display_entity', 'test_serializer_node_display_field');
/**
* A user with administrative privileges to look at test entity and configure views.
......@@ -289,4 +289,16 @@ public function testPreview() {
$this->assertEqual($rendered_json, $expected, 'Ensure the previewed json is escaped.');
}
/**
* Tests the field row style using fieldapi fields.
*/
public function testFieldapiField() {
$this->drupalCreateContentType(array('type' => 'page'));
$node = $this->drupalCreateNode();
$result = $this->drupalGetJSON('test/serialize/node-field');
$this->assertEqual($result[0]['nid'], $node->id());
$this->assertEqual($result[0]['body'], $node->body->processed);
}
}
base_table: node
id: test_serializer_node_display_field
description: ''
tag: ''
label: 'Test serializer display field rows for entity fields'
core: 8.x
display:
default:
display_plugin: default
id: default
display_title: Master
position: ''
display_options:
access:
type: perm
options:
perm: 'access content'
cache:
type: none
query:
type: views_query
exposed_form:
type: basic
style:
type: serializer
row:
type: data_field
fields:
nid:
id: nid
table: node
field: nid
plugin_id: numeric
provider: node
body:
id: body
table: node__body
field: body
relationship: none
group_type: group
admin_label: ''
label: Body
exclude: 0
alter:
alter_text: 0
text: ''
make_link: 0
path: ''
absolute: 0
external: 0
replace_spaces: 0
path_case: none
trim_whitespace: 0
alt: ''
rel: ''
link_class: ''
prefix: ''
suffix: ''
target: ''
nl2br: 0
max_length: ''
word_boundary: 1
ellipsis: 1
more_link: 0
more_link_text: ''
more_link_path: ''
strip_tags: 0
trim: 0
preserve_tags: ''
html: 0
element_type: ''
element_class: ''
element_label_type: ''
element_label_class: ''
element_label_colon: 1
element_wrapper_type: ''
element_wrapper_class: ''
element_default_classes: 1
empty: ''
hide_empty: 0
empty_zero: 0
hide_alter_empty: 1
click_sort_column: value
type: text_default
settings: { }
group_column: value
group_columns: { }
group_rows: true
delta_limit: all
delta_offset: 0
delta_reversed: false
delta_first_last: false
multi_type: separator
separator: ', '
field_api_classes: 0
plugin_id: field
provider: field
title: 'Test serialize'
arguments: { }
rest_export_1:
display_plugin: rest_export
id: rest_export_1
display_title: serializer
position: ''
display_options:
defaults:
access: false
style: false
row: false
path: test/serialize/node-field
access:
type: none
style:
type: serializer
row:
type: data_field
base_field: nid
status: '1'
module: rest_test_views
langcode: und
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment