Score:0

How can I add a custom field?

eg flag

I am using layout paragraph module. I have a "section" paragraph with the layout paragraph behaviour. I want to add a field Background color to the section.

Should I add it inside the layout configuration form in the same way https://www.drupal.org/docs/drupal-apis/layout-api/how-to-register-layouts adds a textfield, or should I add the background color field to the "section" paragraph?

leymannx avatar
ne flag
If this field is never meant to be really printed to the user or to be translated, use a behavior plugin.
Score:2
tg flag

I suggest adding the fields to the section paragraph type.

I've done something similar in the past by adding colour fields (foreground/background) and other properties (margin/padding) to the section paragraph type.

This way you can keep your layouts purely structural, and define all styling on section level, regardless of the chosen layout.

Mira chalak avatar
eg flag
Thank You so much for this clear explanation :)
leymannx avatar
ne flag
If this field is never meant to be really printed to the user or to be translated, use a behavior plugin instead.
Mira chalak avatar
eg flag
@leymannx thanks for your comment ! But could you please tell me what is a "behavior plugin" ? Or could you give me a link to read about it ?
Mira chalak avatar
eg flag
@leymannx I finally opted for adding fields in section paragraoh because i want to add the section title field as well and it translatable so I added it to the section paragraph, I would like to thank you for pointing out to the translation point because that's what made me choose this solution :)
Score:1
cn flag

The Style Options Module was designed just for this purpose by the same team. It's used with their Mercury Editor, but it was designed to separate out these types of style related options from the content of the paragraphs.

Mira chalak avatar
eg flag
Thank You for this clear answer !
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.