Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
Paragraphs should be allowed to be converted in the widget.
If there are similar fields the plugin should work out of the box but it should be possible to go through the paragraphs fields and map them to the target paragraph type.
Similar to Add Above. Enable the convert feature in the field form display.
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
Comment | File | Size | Author |
---|---|---|---|
#22 | paragraphs_conversion-3043559-22.patch | 42.3 KB | weseze |
#21 | paragraphs_conversion-3043559-21.patch | 42.2 KB | sasanikolic |
| |||
#21 | paragraphs_conversion-3043559-21-interdiff.txt | 601 bytes | sasanikolic |
#20 | paragraphs_conversion-3043559-20.patch | 42.11 KB | Berdir |
| |||
#19 | paragraphs_conversion-3043559-19.patch | 42.12 KB | Berdir |
|
Issue fork paragraphs-3043559
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
johnchqueWIP patch. Working now. No tests yet.
Comment #3
johnchqueNow checking the allowed values. Updating the ellipsis by the ellipsis char. Updating the labels of elements introduced here.
Comment #4
johnchqueSorry, some small adjustments. :)
Comment #5
johnchqueGot a problem when using the modal add form.
Comment #6
johnchqueMaking the target types an array so we can have multiple types returned from the conversion operation.
Comment #7
johnchqueSending the parent allowed types to the support method.
Comment #8
johnchqueUpdating patch to allow returning Paragraphs objects so we can reuse them.
Comment #9
mbovan CreditAttribution: mbovan at MD Systems GmbH commentedThis patch fixes a problem if a default language is not the first one in the list when doing conversions.
We noticed this in a client project and @Berdir fixed it so credits to him. :)
I have tried to create content + text paragraphs in one language and then switched it to the other language but I can't reproduce it...
Comment #10
mbovan CreditAttribution: mbovan at MD Systems GmbH commentedI thought that we are missing the alter hook so contrib/custom modules can alter converted paragraphs. It was just undocumented in
paragraphs.api.php
. Fixed that and while here also fixed the code style errors I noticed.Comment #11
mbovan CreditAttribution: mbovan at MD Systems GmbH commentedParagraphsDemoTest
changes are not really related to this. Reverted that.Comment #12
mbovan CreditAttribution: mbovan at MD Systems GmbH commentedProviding a fix for the case when a conversion plugin doesn't return paragraph values but a paragraph entity.
Comment #13
mbovan CreditAttribution: mbovan at MD Systems GmbH commentedThis patch fixes an issue with the conversion hook that was not executed on each converted paragraphs.
Comment #14
mbovan CreditAttribution: mbovan at MD Systems GmbH commentedI updated
hook_paragraphs_conversion()
to document that the hook is not fired for each translation.Comment #15
mbovan CreditAttribution: mbovan at MD Systems GmbH commentedI am providing a patch that improves
Drupal\paragraphs\ParagraphsConversionBase::supports()
to it checks a user has create access to at least one target paragraph type.Comment #16
mbovan CreditAttribution: mbovan at MD Systems GmbH commentedJust noticed we already have this logic in two places in
Drupal\paragraphs\ParagraphsConversionManager
. It has a bug as it doesn't set the flag toFALSE
if a user has no create access.In #15, I moved the check into the base class so plugin implementations could decide whether they want to rely on access checks (best practice) or if they're doing something special. If we are enforcing the access check based on the plugin definition we should then move the similar check for the
source_type
inDrupal\paragraphs\ParagraphsConversionManager
IMHO.Comment #17
mbovan CreditAttribution: mbovan at MD Systems GmbH commentedHere I fixed the original problem described in #16.1.
Comment #18
Primsi CreditAttribution: Primsi at MD Systems GmbH for MD Systems GmbH commentedSmall fix for the error described here #3082542: PHP notice when converting library item
Comment #19
BerdirReroll.
Comment #20
BerdirAnother reroll.
Comment #21
sasanikolic CreditAttribution: sasanikolic at MD Systems GmbH commentedI propose we add the small button class like we did for other buttons (for Claro) in https://www.drupal.org/node/3111075.
Comment #22
weseze CreditAttribution: weseze as a volunteer commentedPatch #21 wasn't working for us against 1.13 release.
Attached is one that applies to 1.13. No changes
Comment #23
BerdirThanks for the reroll. FWIW, I wasn't sure about committing this without getting some inputs about it from others. So if it's useful, let me know :)
Comment #26
BerdirWe've been using this for years. Committed and created a basic documentation page: https://www.drupal.org/docs/contributed-modules/paragraphs/converting-pa...
Comment #27
pp.panatom CreditAttribution: pp.panatom commented@Berdir
on documentation page (also in related test),
function name `submitConversion()` should be `convert()`?