Support from Acquia helps fund testing for Drupal Acquia logo

Comments

chrissnyder created an issue. See original summary.

jacobfrancke@gmail.com’s picture

+1

thiagomoraesp’s picture

+1

kriboogh’s picture

The summary function is missing, which is needed to display the form.

I'll try to cook up a patch, but in the mean time just add this method to DisplayFieldCopy.php

/**
   * {@inheritdoc}
   */
  public function settingsSummary($settings) {

    /** @var FormatterInterface $formatter */
    $formatter = $this->getFormatter([
      'type' => $this->getFieldConfiguration()['formatter'],
    ]);

    if ($formatter) {
      return $formatter->settingsSummary();
    }
    else {
      return [];
    }
  }
kriboogh’s picture

To make this work properly this also needs a patch for ds in the file field_ui.inc at line 1117.

foreach ($fields as $key => $field) {
    if (isset($field_settings[$key]['formatter'])) {
      $field['formatter'] = $field_settings[$key]['formatter'];
    }

Patch is coming up just need the time to make it.

kriboogh’s picture

kriboogh’s picture

Extra fix, apparently the prepareView isn't called before the elements are handled.

TipiT’s picture

I cant't apply the patch against the 1.0 release.

Why is it made for alpha3 version (like it says in the version)?

davidwbarratt’s picture

Issue tags: +Needs reroll
arunkumark’s picture

Status: Active » Needs review
FileSize
1.43 KB

Hi,

I have rerolled the patch for the latest version of Display Field Copy module.

TipiT’s picture

#10 Works. Thank you!

However I get a Notice [1] on node display page (admin/structure/types/manage/event/display) if the Field copy is not placed on the layout. Meaning it is disabled.

[1] Notice: Undefined index: formatter in Drupal\display_field_copy\Plugin\DsField\DisplayFieldCopy->settingsSummary() (line 134 of modules/contrib/display_field_copy/src/Plugin/DsField/DisplayFieldCopy.php).
Drupal\display_field_copy\Plugin\DsField\DisplayFieldCopy->settingsSummary(Array) (Line: 631)
ds_field_settings_summary(Object, Array, Object) (Line: 1248)
_ds_field_ui_fields('node', 'event', 'default', Array, Object) (Line: 46)
ds_field_ui_fields_layouts(Array, Object) (Line: 247)
ds_form_entity_view_display_edit_form_alter(Array, Object, 'entity_view_display_edit_form') (Line: 501)
Drupal\Core\Extension\ModuleHandler->alter('form', Array, Object, 'entity_view_display_edit_form') (Line: 819)
Drupal\Core\Form\FormBuilder->prepareForm('entity_view_display_edit_form', Array, Object) (Line: 272)
Drupal\Core\Form\FormBuilder->buildForm('entity_view_display_edit_form', Object) (Line: 74)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 574)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
call_user_func_array(Object, Array) (Line: 144)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 64)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 99)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 78)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 50)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 656)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
Notice: Undefined index: formatter in Drupal\display_field_copy\Plugin\DsField\DisplayFieldCopy->settingsSummary() (line 134 of modules/contrib/display_field_copy/src/Plugin/DsField/DisplayFieldCopy.php).
Drupal\display_field_copy\Plugin\DsField\DisplayFieldCopy->settingsSummary(Array) (Line: 631)
ds_field_settings_summary(Object, Array, Object) (Line: 1248)
_ds_field_ui_fields('node', 'event', 'default', Array, Object) (Line: 46)
ds_field_ui_fields_layouts(Array, Object) (Line: 247)
ds_form_entity_view_display_edit_form_alter(Array, Object, 'entity_view_display_edit_form') (Line: 501)
Drupal\Core\Extension\ModuleHandler->alter('form', Array, Object, 'entity_view_display_edit_form') (Line: 819)
Drupal\Core\Form\FormBuilder->prepareForm('entity_view_display_edit_form', Array, Object) (Line: 272)
Drupal\Core\Form\FormBuilder->buildForm('entity_view_display_edit_form', Object) (Line: 74)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 574)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
call_user_func_array(Object, Array) (Line: 144)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 64)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 99)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 78)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 50)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 656)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

TipiT’s picture

Version: 8.x-1.0-alpha3 » 8.x-1.0
Status: Needs review » Reviewed & tested by the community
TipiT’s picture

TipiT’s picture

davidwbarratt’s picture

Status: Reviewed & tested by the community » Needs work

The notice has to be fixed.

arunkumark’s picture

@TipiT can you share the Drupal core version you are using?

DiegoPino’s picture

Version: 8.x-1.0 » 8.x-1.1
Issue summary: View changes
FileSize
2.57 KB

Hi, the issue reported by @TipiT on applying the provided patch still persists. Problem is related to the fact that Disabled fields do not store configurations (they are basically removed from a Display, which means 'formatter' key simply does not exist at field level). The following patch applies cleanly over 8.x-1.x .
Side note: because the way Ds handles the Display field list form (and the fact that settings totally depend on having a Summary present) , if you move a field from enabled to disabled, save and then you move it back to enabled, expected behavior on setting a formatter widget is a bit confusing. You have to save the changes to current display before the Widget settings appear again. Let me know if this fixes the current issue and maybe we could add a more informative message (Somewhere?) about this on the UI on a separate one or directly on Ds.

I also did a minor change in the class definition. It feels more portable if the class implements directly DsFieldInterface Interface instead of cherry-picking only the container injection piece which is also included in DsFieldInterface. That way this field can be used every-time a DsField Interface is expected.

(My first Drupal contribution, so please forgive any mistakes in the workflow)

kriboogh’s picture

Issue summary: View changes
Status: Needs work » Needs review

Kicking the testbot.

kriboogh’s picture

ah,.. no testbot, but still needs review :-)

DiegoPino’s picture

Hi @davidwbarratt, if you have some time, could you please give this patch a review? Thanks

mansspams’s picture

Status: Needs review » Reviewed & tested by the community

Patch #17 works IRL

davidwbarratt’s picture

Version: 8.x-1.1 » 8.x-1.x-dev
Status: Reviewed & tested by the community » Needs review
Issue tags: -Needs reroll
FileSize
2.45 KB
2.93 KB

I made a few formatting changes, please retest. :)

DiegoPino’s picture

Status: Needs review » Reviewed & tested by the community

Hi @davidwbarratt, thanks! looks good. Thanks for the corrections.

DiegoPino’s picture

Any change this getting merged soon?

Thanks

davidwbarratt’s picture

Status: Reviewed & tested by the community » Fixed
DiegoPino’s picture

@davidwbarratt thank you!

Status: Fixed » Closed (fixed)

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