Commit d60d9fd7 authored by Italo Mairo's avatar Italo Mairo Committed by Justin Toupin
Browse files

Issue #3086805 by itamair, justin2pin, breezeweb: Layout Paragraphs cannot be...

Issue #3086805 by itamair, justin2pin, breezeweb: Layout Paragraphs cannot be updated, when Host Entity Revisions disabled
parent 5199a797
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -13,6 +13,7 @@ use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Entity\EntityTypeBundleInfoInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Render\Renderer;
use Drupal\paragraphs\ParagraphInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\Core\Plugin\PluginFormInterface;
use Drupal\Core\Plugin\PluginWithFormsInterface;
@@ -979,8 +980,15 @@ class EntityReferenceLayoutWidget extends WidgetBase implements ContainerFactory
   * {@inheritdoc}
   */
  public function massageFormValues(array $values, array $form, FormStateInterface $form_state) {
    foreach ($values as $delta => $value) {
    foreach ($values as $delta => &$item) {
      unset($values[$delta]['actions']);
      if ($item['entity'] instanceof ParagraphInterface) {
        /** @var \Drupal\paragraphs\Entity\Paragraph $paragraph_entity */
        $paragraph_entity = $item['entity'];
        $paragraph_entity->setNeedsSave(TRUE);
        $item['target_id'] = $paragraph_entity->id();
        $item['target_revision_id'] = $paragraph_entity->getRevisionId();
      }
    }
    return $values;
  }