Commit a7a9e365 authored by alexpott's avatar alexpott

Issue #2558061 by joelpittet, lauriii: Nested form tag in views forms

parent 247c9a4f
......@@ -25,7 +25,7 @@ public function getFormId() {
public function buildForm(array $form, FormStateInterface $form_state, ViewExecutable $view = NULL, $output = []) {
$form['#prefix'] = '<div class="views-form">';
$form['#suffix'] = '</div>';
$form['#theme'] = 'form';
$form['#pre_render'][] = 'views_pre_render_views_form_views_form';
// Add the output markup to the form array so that it's included when the form
......
<?php
/**
* @file
* Contains \Drupal\views\Tests\Plugin\ViewsFormTest.
*/
namespace Drupal\views\Tests\Plugin;
use Drupal\simpletest\WebTestBase;
use Drupal\views\Views;
/**
* Tests Views forms functionality.
*
* @group views
*/
class ViewsFormTest extends WebTestBase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array('action_bulk_test');
/**
* Tests the Views form wrapper.
*/
public function testFormWrapper() {
$this->drupalGet('test_bulk_form');
// Ensure we have the form tag on the page.
$xpath = $this->cssSelect('.views-form form');
$this->assertIdentical(count($xpath), 1, 'There is one views form on the page.');
// Ensure we don't have nested form elements.
$result = (bool) preg_match('#<form[^>]*?>(?!/form).*<form#s', $this->getRawContent());
$this->assertFalse($result, 'The views form element is not nested.');
}
}
......@@ -676,10 +676,6 @@ function views_pre_render_views_form_views_form($element) {
$output = str_replace($search, $replace, drupal_render($element['output']));
$element['output'] = ['#markup' => ViewsRenderPipelineSafeString::create($output)];
// Sort, render and add remaining form fields.
$children = Element::children($element, TRUE);
$element['#children'] = drupal_render_children($element, $children);
return $element;
}
......
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