Issue #2606548 by Lendude, dawehner, alexpott, catch, tim.plunkett, xjm, damiankloip: \Drupal\rest\Plugin\views\row\DataFieldRow::render should take into account the 'exclude' flag
parent
027c0d82d1
commit
e3de68b0dd
|
@ -88,6 +88,10 @@ class DataFieldRow extends RowPluginBase {
|
||||||
|
|
||||||
if ($fields = $this->view->display_handler->getOption('fields')) {
|
if ($fields = $this->view->display_handler->getOption('fields')) {
|
||||||
foreach ($fields as $id => $field) {
|
foreach ($fields as $id => $field) {
|
||||||
|
// Don't show the field if it has been excluded.
|
||||||
|
if (!empty($field['exclude'])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
$form['field_options'][$id]['field'] = array(
|
$form['field_options'][$id]['field'] = array(
|
||||||
'#markup' => $id,
|
'#markup' => $id,
|
||||||
);
|
);
|
||||||
|
@ -138,6 +142,10 @@ class DataFieldRow extends RowPluginBase {
|
||||||
$output = array();
|
$output = array();
|
||||||
|
|
||||||
foreach ($this->view->field as $id => $field) {
|
foreach ($this->view->field as $id => $field) {
|
||||||
|
// Don't render anything if this field is excluded.
|
||||||
|
if (!empty($field->options['exclude'])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
// If the raw output option has been set, just get the raw value.
|
// If the raw output option has been set, just get the raw value.
|
||||||
if (!empty($this->rawOutputOptions[$id])) {
|
if (!empty($this->rawOutputOptions[$id])) {
|
||||||
$value = $field->getValue($row);
|
$value = $field->getValue($row);
|
||||||
|
|
|
@ -470,6 +470,32 @@ class StyleSerializerTest extends PluginTestBase {
|
||||||
$this->assertIdentical($values['created'], $view->result[$index]->views_test_data_created, 'Expected raw created value found.');
|
$this->assertIdentical($values['created'], $view->result[$index]->views_test_data_created, 'Expected raw created value found.');
|
||||||
$this->assertIdentical($values['name'], $view->result[$index]->views_test_data_name, 'Expected raw name value found.');
|
$this->assertIdentical($values['name'], $view->result[$index]->views_test_data_name, 'Expected raw name value found.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Test result with an excluded field.
|
||||||
|
$view->setDisplay('rest_export_1');
|
||||||
|
$view->displayHandlers->get('rest_export_1')->overrideOption('fields', [
|
||||||
|
'name' => [
|
||||||
|
'id' => 'name',
|
||||||
|
'table' => 'views_test_data',
|
||||||
|
'field' => 'name',
|
||||||
|
'relationship' => 'none',
|
||||||
|
],
|
||||||
|
'created' => [
|
||||||
|
'id' => 'created',
|
||||||
|
'exclude' => TRUE,
|
||||||
|
'table' => 'views_test_data',
|
||||||
|
'field' => 'created',
|
||||||
|
'relationship' => 'none',
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
$view->save();
|
||||||
|
$this->executeView($view);
|
||||||
|
foreach ($this->drupalGetJSON('test/serialize/field') as $index => $values) {
|
||||||
|
$this->assertTrue(!isset($values['created']), 'Excluded value not found.');
|
||||||
|
}
|
||||||
|
// Test that the excluded field is not shown in the row options.
|
||||||
|
$this->drupalGet('admin/structure/views/nojs/display/test_serializer_display_field/rest_export_1/row_options');
|
||||||
|
$this->assertNoText('created');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue