Commit 489c6f75 authored by webchick's avatar webchick

Issue #1828498 by dawehner: Fixed Query settings aren't saved.

parent 5cf538e4
......@@ -2212,7 +2212,7 @@ public function submitOptionsForm(&$form, &$form_state) {
}
break;
case 'query':
$plugin = $this->get_plugin('query');
$plugin = $this->getPlugin('query');
if ($plugin) {
$plugin->submitOptionsForm($form['query']['options'], $form_state);
$this->setOption('query', $form_state['values'][$section]);
......
......@@ -246,7 +246,6 @@ public function buildOptionsForm(&$form, &$form_state) {
'#default_value' => implode(', ', $this->options['query_tags']),
'#element_validate' => array('views_element_validate_tags'),
);
$form_state['build_info']['files']['foo'] = drupal_get_path('module', 'views') . '/lib/Drupal/views/Plugin/Query/SqlQuery.php';
}
/**
......
<?php
/**
* @file
* Definition of Drupal\views\Tests\UI\QueryTest.
*/
namespace Drupal\views\Tests\UI;
use Drupal\views\Tests\ViewTestBase;
use Drupal\views_test_data\Plugin\views\query\QueryTest as QueryTestPlugin;
/**
* Tests query plugins.
*/
class QueryTest extends UITestBase {
public static function getInfo() {
return array(
'name' => 'Query: UI',
'description' => 'Tests query plugins UI.',
'group' => 'Views UI'
);
}
/**
* Overrides \Drupal\views\Tests\ViewTestBase::viewsData().
*/
protected function viewsData() {
$data = parent::viewsData();
$data['views_test_data']['table']['base']['query_id'] = 'query_test';
return $data;
}
/**
* Tests query plugins settings.
*/
public function testQueryUI() {
// Save some query settings.
$query_settings_path = "admin/structure/views/nojs/display/test_view/default/query";
$random_value = $this->randomName();
$this->drupalPost($query_settings_path, array('query[options][test_setting]' => $random_value), t('Apply'));
$this->drupalPost(NULL, array(), t('Save'));
// Check that the settings are saved into the view itself.
$view = views_get_view('test_view');
$view->initDisplay();
$view->initQuery();
$this->assertEqual($random_value, $view->query->options['test_setting'], 'Query settings got saved');
}
}
......@@ -27,6 +27,29 @@ class QueryTest extends QueryPluginBase {
protected $allItems = array();
protected $orderBy = array();
/**
* Implements \Drupal\views\Plugin\views\query\QueryPluginBase::defineOptions().
*/
protected function defineOptions() {
$options = parent::defineOptions();
$options['test_setting'] = array('default' => '');
return $options;
}
/**
* Implements \Drupal\views\Plugin\views\query\QueryPluginBase::buildOptionsForm().
*/
public function buildOptionsForm(&$form, &$form_state) {
parent::buildOptionsForm($form, $form_state);
$form['test_setting'] = array(
'#title' => t('Test setting'),
'#type' => 'textfield',
'#default_value' => $this->options['test_setting'],
);
}
/**
* Sets the allItems property.
*
......
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