Commit 94fb2afd authored by catch's avatar catch

Issue #2450151 by yched: Don't try to render all fields (including hidden...

Issue #2450151 by yched: Don't try to render all fields (including hidden ones) for single entity display
parent 287c6be2
......@@ -154,8 +154,9 @@ public function buildForm(FieldableEntityInterface $entity, array &$form, FormSt
$form += array('#parents' => array());
// Let each widget generate the form elements.
foreach ($entity as $name => $items) {
foreach ($this->getComponents() as $name => $options) {
if ($widget = $this->getRenderer($name)) {
$items = $entity->get($name);
$items->filterEmptyItems();
$form[$name] = $widget->form($items, $form, $form_state);
$form[$name]['#access'] = $items->access('edit');
......@@ -163,7 +164,7 @@ public function buildForm(FieldableEntityInterface $entity, array &$form, FormSt
// Assign the correct weight. This duplicates the reordering done in
// processForm(), but is needed for other forms calling this method
// directly.
$form[$name]['#weight'] = $this->getComponent($name)['weight'];
$form[$name]['#weight'] = $options['weight'];
}
}
......
......@@ -223,32 +223,32 @@ public function buildMultiple(array $entities) {
}
// Run field formatters.
foreach ($this->getFieldDefinitions() as $field_name => $definition) {
if ($formatter = $this->getRenderer($field_name)) {
foreach ($this->getComponents() as $name => $options) {
if ($formatter = $this->getRenderer($name)) {
// Group items across all entities and pass them to the formatter's
// prepareView() method.
$grouped_items = array();
foreach ($entities as $id => $entity) {
$items = $entity->get($field_name);
$items = $entity->get($name);
$items->filterEmptyItems();
$grouped_items[$id] = $items;
}
$formatter->prepareView($grouped_items);
// Then let the formatter build the output for each entity.
foreach ($entities as $key => $entity) {
$items = $entity->get($field_name);
$build_list[$key][$field_name] = $formatter->view($items);
$build_list[$key][$field_name]['#access'] = $items->access('view');
foreach ($entities as $id => $entity) {
$items = $grouped_items[$id];
$build_list[$id][$name] = $formatter->view($items);
$build_list[$id][$name]['#access'] = $items->access('view');
}
}
}
foreach ($entities as $key => $entity) {
foreach ($entities as $id => $entity) {
// Assign the configured weights.
foreach ($this->getComponents() as $name => $options) {
if (isset($build_list[$key][$name])) {
$build_list[$key][$name]['#weight'] = $options['weight'];
if (isset($build_list[$id][$name])) {
$build_list[$id][$name]['#weight'] = $options['weight'];
}
}
......
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