Problem:
Since erl_restriction uses its own field type, we are confronted with the problem that if we want to use the module for existing projects, it is difficult to migrate the data. We need to migrate all data form the entity_reference_layout field to the the new erl_restriction field, for all content types using entity_reference_layout.

Proposed solution:
It would be nice if we could set the restrictions in a widget for the entity_reference_layout field instead of using a new type. It would make it a lot easier to use the module for projects that already use entity_reference_layout.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

InaW created an issue. See original summary.

waluigi’s picture

Thanks for the proposal, this is a great idea.
I created a patch where you have to choose the allowed paragraph types in the widget settings instead of the field settings. As you described it, you now can simply select the other widget and afterwards all the allowed paragraphs.

I would appreciate of someone could quickly test it as well.

dermario’s picture

Status: Active » Needs review
InaW’s picture

Status: Needs review » Needs work

@waluigi Thanks for your great work. I tested your patch #2 and it seems to work fine. I enabled the widget on an existing entity_reference_layout field and was able to successfully restrict the paragraphs per layout.

In the comments below I listed some small code improvements, that should be fixed.

  1. +++ b/src/Plugin/Field/FieldWidget/ErlRestrictionWidget.php
    @@ -67,4 +76,54 @@ class ErlRestrictionWidget extends EntityReferenceLayoutWidget implements Contai
    +/**
    +   * Default settings for widget.
    

    Indentation seems to be wrong

  2. +++ b/src/Plugin/Field/FieldWidget/ErlRestrictionWidget.php
    @@ -67,4 +76,54 @@ class ErlRestrictionWidget extends EntityReferenceLayoutWidget implements Contai
    +  /**
    +   * @param array $form
    +   * @param \Drupal\Core\Form\FormStateInterface $form_state
    +   *
    +   * @return array
    

    Comment description is missing

  3. +++ b/src/Plugin/Field/FieldWidget/ErlRestrictionWidget.php
    @@ -67,4 +76,54 @@ class ErlRestrictionWidget extends EntityReferenceLayoutWidget implements Contai
    +    $form = parent::settingsForm($form, $form_state); // TODO: Change the autogenerated stub
    

    This TODO is obsolete

dermario’s picture

Status: Needs work » Needs review
FileSize
5.93 KB
2.15 KB

I performed the code cleanups mentioned in #4 and fixed some more findings.

Silent-Murmur’s picture

I checked it and it looks fine for me now.

Silent-Murmur’s picture

Status: Needs review » Reviewed & tested by the community

  • dermario committed 7d8ed9f on 8.x-1.x
    Issue #3086766 by dermario, waluigi, InaW, Silent-Murmur: Set...
dermario’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed, thanks to all.

Status: Fixed » Closed (fixed)

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