Verified Commit 5888e036 authored by Lee Rowlands's avatar Lee Rowlands
Browse files

Issue #2917239 by Lendude, dww, iStryker: Form is built when not using fields

parent 5e24bdc8
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -2450,11 +2450,13 @@ public function buildThemeFunctions($hook) {
   *   FALSE otherwise.
   */
  public function hasFormElements() {
    if ($this->getDisplay()->usesFields()) {
      foreach ($this->field as $field) {
        if (method_exists($field, 'viewsForm')) {
          return TRUE;
        }
      }
    }
    $area_handlers = array_merge(array_values($this->header), array_values($this->footer));
    $empty = empty($this->result);
    foreach ($area_handlers as $area) {
+27 −0
Original line number Diff line number Diff line
@@ -178,3 +178,30 @@ display:
        empty: false
        style: false
      path: test_bulk_form_empty
  page_3:
    id: page_3
    display_title: 'Page 3'
    display_plugin: page
    position: 3
    display_options:
      style:
        type: grid
        options:
          grouping: { }
          columns: 3
          automatic_width: true
          alignment: horizontal
          row_class_custom: ''
          row_class_default: true
          col_class_custom: ''
          col_class_default: true
      row:
        type: 'entity:node'
        options:
          relationship: none
          view_mode: teaser
      defaults:
        style: false
        row: false
      display_extenders: { }
      path: display-without-fields
+6 −0
Original line number Diff line number Diff line
@@ -34,6 +34,12 @@ public function testFormWrapper() {
    // Ensure we don't have nested form elements.
    $result = (bool) preg_match('#<form[^>]*?>(?!/form).*<form#s', $this->getSession()->getPage()->getContent());
    $this->assertFalse($result, 'The views form element is not nested.');

    // Test the form isn't shown when the display doesn't use fields.
    $this->drupalGet('display-without-fields');
    // Ensure there's no form.
    $xpath = $this->cssSelect('.views-form form');
    $this->assertCount(0, $xpath);
  }

}