Commit e686c9d1 authored by alexpott's avatar alexpott

Issue #2550225 by swentel, yched, Wim Leers, aspilicious:...

Issue #2550225 by swentel, yched, Wim Leers, aspilicious: quickedit_test_entity_view_alter() creates a non compliant field render array
parent f5647da8
......@@ -1480,11 +1480,7 @@ function template_preprocess_field(&$variables, $hook) {
// readers.
$variables['label'] = $element['#title'];
// @todo Check for is_object() required due to pseudo field used in
// quickedit_test_entity_view_alter(). Remove this check after this is fixed
// in https://www.drupal.org/node/2550225.
$variables['multiple'] = is_object($element['#items']) ? $element['#items']->getFieldDefinition()->getFieldStorageDefinition()->isMultiple() : FALSE;
$variables['multiple'] = $element['#items']->getFieldDefinition()->getFieldStorageDefinition()->isMultiple();
static $default_attributes;
if (!isset($default_attributes)) {
......
......@@ -130,10 +130,9 @@ function quickedit_preprocess_field(&$variables) {
return;
}
// Fields that are not part of the entity (i.e. dynamically injected "pseudo
// fields") and computed fields are not editable.
// Fields that are computed fields are not editable.
$definition = $entity->getFieldDefinition($element['#field_name']);
if ($definition && !$definition->isComputed()) {
if (!$definition->isComputed()) {
$variables['attributes']['data-quickedit-field-id'] = $entity->getEntityTypeId() . '/' . $entity->id() . '/' . $element['#field_name'] . '/' . $element['#language'] . '/' . $element['#view_mode'];
}
}
......
......@@ -396,20 +396,6 @@ public function testTitleBaseField() {
}
}
/**
* Tests that Quick Edit doesn't make pseudo fields or computed fields
* editable.
*/
public function testPseudoFields() {
\Drupal::service('module_installer')->install(array('quickedit_test'));
$this->drupalLogin($this->authorUser);
$this->drupalGet('node/1');
// Check that the data- attribute is not added.
$this->assertNoRaw('data-quickedit-field-id="node/1/quickedit_test_pseudo_field/en/default"');
}
/**
* Tests that Quick Edit doesn't make fields rendered with display options
* editable.
......
......@@ -9,35 +9,6 @@
use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
use Drupal\Core\Language\LanguageInterface;
/**
* Implements hook_entity_view_alter().
*/
function quickedit_test_entity_view_alter(&$build, EntityInterface $entity, EntityViewDisplayInterface $display) {
if ($entity->getEntityTypeId() == 'node' && $entity->bundle() == 'article') {
$build['pseudo'] = array(
'#theme' => 'field',
'#title' => 'My pseudo field',
'#field_name' => 'quickedit_test_pseudo_field',
'#label_display' => 'Label',
'#entity_type' => $entity->getEntityTypeId(),
'#bundle' => $entity->bundle(),
'#language' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
'#field_type' => 'pseudo',
'#view_mode' => 'default',
'#object' => $entity,
'#access' => TRUE,
'#items' => array(
0 => array(
'value' => 'pseudo field',
),
),
0 => array(
'#markup' => 'pseudo field',
),
);
}
}
/**
* Implements hook_quickedit_render_field().
*/
......
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