Issue #1967124 by damiankloip, dawehner | xjm: Bulk action views array to string conversion when there are no results.

8.0.x
webchick 2014-02-06 23:15:09 -08:00
parent 39a0b439f6
commit 255a33f541
3 changed files with 35 additions and 2 deletions

View File

@ -35,6 +35,11 @@ class BulkFormTest extends WebTestBase {
* Tests the bulk form.
*/
public function testBulkForm() {
// First, test an empty bulk form with the default style plugin to make sure
// the empty region is rendered correctly.
$this->drupalGet('test_bulk_form_empty');
$this->assertText(t('This view is empty.'), 'Empty text found on empty bulk form.');
$nodes = array();
for ($i = 0; $i < 10; $i++) {
// Ensure nodes are sorted in the same order they are inserted in the

View File

@ -150,6 +150,27 @@ display:
position: null
display_options:
path: test_bulk_form
page_2:
display_plugin: page
id: page_2
display_title: Page
position: null
display_options:
path: test_bulk_form_empty
defaults:
style: false
empty: false
style:
type: default
empty:
area:
id: area
table: views
field: area
empty: true
content: 'This view is empty.'
plugin_id: text_custom
provider: views
base_field: nid
status: true
module: views

View File

@ -133,8 +133,15 @@ function template_preprocess_views_view(&$variables) {
if (views_view_has_form_elements($view)) {
// Copy the rows so as not to modify them by reference when rendering.
$rows = $variables['rows'];
$rows = drupal_render($rows);
$output = !empty($rows) ? $rows : $variables['empty'];
// Only render row output if there are rows. Otherwise, render the empty
// region.
if (!empty($rows)) {
$output = drupal_render($rows);
}
else {
$empty = $variables['empty'];
$output = drupal_render($empty);
}
$container = \Drupal::getContainer();
$form_object = new ViewsForm($container->get('controller_resolver'), $container->get('url_generator'), $container->get('request'), $view->storage->id(), $view->current_display);