Commit dfce8c07 authored by alexpott's avatar alexpott

Issue #2087069 by damiankloip: Fixed Field language options do not work.

parent 39265928
......@@ -1585,24 +1585,20 @@ public function buildOptionsForm(&$form, &$form_state) {
$this->view->query->buildOptionsForm($form['query']['options'], $form_state);
}
break;
case 'field_language':
case 'field_langcode':
$form['#title'] .= t('Field Language');
$entities = entity_get_info();
$entity_tables = array();
$has_translation_handlers = FALSE;
foreach ($entities as $type => $entity_info) {
$entity_tables[] = $entity_info['base_table'];
if (!empty($entity_info['translation'])) {
$has_translation_handlers = TRUE;
$translatable_entity_tables = array();
foreach (\Drupal::entityManager()->getDefinitions() as $entity_info) {
if (isset($entity_info['base_table']) && !empty($entity_info['translatable'])) {
$translatable_entity_tables[] = $entity_info['base_table'];
}
}
// Doesn't make sense to show a field setting here if we aren't querying
// an entity base table. Also, we make sure that there's at least one
// entity type with a translation handler attached.
if (in_array($this->view->storage->get('base_table'), $entity_tables) && $has_translation_handlers) {
if (in_array($this->view->storage->get('base_table'), $translatable_entity_tables)) {
$languages = array(
'***CURRENT_LANGUAGE***' => t("Current user's language"),
'***DEFAULT_LANGUAGE***' => t("Default site language"),
......
......@@ -19,7 +19,7 @@ class ViewEditTest extends UITestBase {
*
* @var array
*/
public static $testViews = array('test_view');
public static $testViews = array('test_view', 'test_display');
public static function getInfo() {
return array(
......@@ -45,4 +45,29 @@ public function testDeleteLink() {
$this->assertFalse($view instanceof View);
}
/**
* Tests the 'Other' options category on the views edit form.
*/
public function testEditFormOtherOptions() {
// Test the Field language form.
$this->drupalGet('admin/structure/views/view/test_view');
$langcode_url = 'admin/structure/views/nojs/display/test_view/default/field_langcode';
$this->assertLinkByHref($langcode_url);
$this->assertLink(t("Current user's language"));
// Click the link and check the form before language is enabled.
$this->drupalGet($langcode_url);
$this->assertResponse(200);
$this->assertText(t("You don't have translatable entity types."));
// A node view should have language options.
module_enable(array('node', 'language'));
$this->resetAll();
$this->rebuildContainer();
entity_info_cache_clear();
$this->drupalGet('admin/structure/views/nojs/display/test_display/page_1/field_langcode');
$this->assertResponse(200);
$this->assertFieldByName('field_langcode', '***CURRENT_LANGUAGE***');
$this->assertFieldByName('field_langcode_add_to_query', TRUE);
}
}
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