I was thinking of the ability to add an option to bind view mode select field with a form mode of the paragraph.
If the form mode with the same id will exist, then the paragraph form will be replaced with this specific form mode.
There are a few challenges here... First is to replace the paragraph form dynamically via ajax. I was looking into Paragraphs module source code and seems like it might be cumbersome to accomplish such functionality. At least I wasn't able to see an easy way at a first glance.
The second thing is that I hope that all the form values will be preserved. I would like to avoid such cases when changing the view mode value wipes all the paragraph values.
I don't have enough time to implement such a feature, so that's why I'm opening this issue for a community. Any help with that will be appreciated.

Comments

sayco created an issue. See original summary.

JFKiwad’s picture

+1

sayco’s picture

Issue summary: View changes
sayco’s picture

Status: Active » Needs work
sime’s picture

I like this approach because it would open up the ability to do nice things like control the form in twig, I think?

My experience with this type of functionality is using form #states to attach visible/required events based on the view mode selector. But this had bad DX, and when bugs occur in core it's a bit frustrating.

sime’s picture

Version: 8.x-1.x-dev » 3.x-dev
sayco’s picture

I have some progress on this issue. I hope I'll be able to push something to dev within a few weeks.

  • sayco committed 0ecdb89f on 3.x
    Issue #3150153 by sayco: Bind paragraph view mode with form mode
    

  • sayco committed 75e81f64 on 3.x
    Issue #3150153 by sayco: Add missing doccomment, typo fixes
    
sayco’s picture

Status: Needs work » Fixed

Finally, I've managed to make it work! The latest changes have been pushed to the dev branch. Hope some of the sites will start using it and we will receive a valuable feedback

sayco’s picture

  • sayco committed ec2060f3 on 3.x
    Issue #3150153 by sayco: Change function implementation for hooks with...
renatog’s picture

Great, thank you

renatog’s picture

Created this task to update the hook_help with this information

Status: Fixed » Closed (fixed)

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