Updated: Comment #N

Problem/Motivation

Go to edit any view, under "Advanced tab" click on "Field language" options.. You will get an empty form. This form also throws errors by assuming all entity info items will have a base table.

Proposed resolution

The DisplayPluginBase buildOptionsForm switch statement is for 'field_language' but the link (and other places) have been changed to 'field_langcode'. Change this switch case to 'field_langcode'

Remaining tasks

Review fix, tests

User interface changes

A fixed Field language form.

API changes

None

CommentFileSizeAuthor
#15 langcode.jpg243.06 KBAnonymous (not verified)
#2 2087069-2-tests-only.patch1.75 KBdamiankloip
#2 2087069-2.patch3.64 KBdamiankloip
#1 2087069.patch1.16 KBdamiankloip
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

damiankloip’s picture

FileSize
1.16 KB

Here is a fix, haven't got round to the tests yet.

damiankloip’s picture

Status: Active » Needs review
Issue tags: -Needs tests
FileSize
3.64 KB
1.75 KB

Ok, changed the logic a bit as it seems pretty flaky at the moment. It basically only works in a normal install because the custom_block entity type have an item in it's 'translation' array in entity_info. So it seems like the $has_translation_handlers is not really working as it should? I've changed this to check the 'translatable' key in entity_info instead, and only add tables to the array that are translatable, then check against that.

Thoughts?

Status: Needs review » Needs work
Issue tags: -VDC

The last submitted patch, 2087069-2.patch, failed testing.

jibran’s picture

Status: Needs work » Needs review

#2: 2087069-2.patch queued for re-testing.

Status: Needs review » Needs work

The last submitted patch, 2087069-2.patch, failed testing.

damiankloip’s picture

Status: Needs work » Needs review

#2: 2087069-2.patch queued for re-testing.

damiankloip’s picture

Issue tags: +VDC

#2: 2087069-2-tests-only.patch queued for re-testing.

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

This seems to be a patch which could be backported to d7?

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed dfce8c0 and pushed to 8.x. Thanks!

Gábor Hojtsy’s picture

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

Updated issue summary.

Anonymous’s picture

Issue summary: View changes

I have a custom entity with custom fields displaying in Views and I'm getting this notice:

Notice: Undefined index: field_language in Drupal\field\Plugin\views\field\Field->field_langcode() (line 861 of core/modules/field/lib/Drupal/field/Plugin/views/field/Field.php).

There is 'field_langcode' but not 'field_language' key in Drupal\field\Plugin\views\field\Field->view->display_handler->options array with " ***CURRENT_LANGUAGE***" as value.

If I rename the 'field_language' to 'field_langcode' I get:

Recoverable fatal error: Object of class Drupal\Core\Language\Language could not be converted to string in Drupal\field\Plugin\views\field\Field->field_langcode() (line 862 of core/modules/field/lib/Drupal/field/Plugin/views/field/Field.php).

Could this be the same issue?

Anonymous’s picture

Status: Closed (fixed) » Active
Anonymous’s picture

BTW: the error is triggered by 'body' field. Here is the config:

id: myentity.body
uuid: ...
status: true
langcode: en
name: body
entity_type: myentity
type: text_with_summary
settings: {  }
module: text
locked: true
cardinality: 1
translatable: true
indexes: {  }

And here is how the instance is created:

$instance = Field::fieldInfo()->getInstance($entity_type, $bundle, 'body');
  if (empty($instance)) {
    entity_create('field_instance_config', array(
      'field_name' => 'body',
      'entity_type' => $entity_type,
      'bundle' => $bundle,
      'label' => 'Body',
      'description' => 'Describe this entry.',
      'settings' => array('display_summary' => TRUE, 'text_processing' => 1),
    ))->save();
    entity_get_form_display($entity_type, $bundle, 'default')
      ->setComponent('body', array('type' => 'text_textarea_with_summary'))
      ->save();
    entity_get_display($entity_type, $bundle, 'default')
      ->setComponent('body', array('label' => 'hidden', 'type' => 'text_default', 'weight' => 0))
      ->save();
  }
Anonymous’s picture

FileSize
243.06 KB

And this is content of /core\modules\field\lib\Drupal\field\Plugin\views\field\Field->view->display_handler->options

dsm

Anonymous’s picture

I've noticed that the field.field.node.body.yml has 'translatable' set to false. That's probably why my body is throwing errors and node is not.

dawehner’s picture

Status: Active » Fixed

Please open a follow up and not reopen an existing issue. Thank you!

Anonymous’s picture

Sure, I just wasn't sure if this is the same issue or not.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.