When a paragraph field is configured to add a single paragraphs type, it is more intuitive to show the Widget's title setting in the add button instead of the paragraphs type label.

Example

Field Hero:
- Configured for the "media" paragraphs type.
- Form Widget Title Setting: "Hero".

Add Button:
Current Paragraphs: "Add Media".
Desired: "Add Hero"

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

recrit created an issue. See original summary.

recrit’s picture

The attached patch is applied to the Experimental widget. A similar change could be applied to the "Classic" widget if needed.

Status: Needs review » Needs work

The last submitted patch, 2: paragraphs-single-type-add-button-2884395-2.patch, failed testing. View results

miro_dietiker’s picture

I'm confused now. :-)

Why should this be more intuitive only for single cases?

Note that we also experiment with removing the field label if a paragraph type has only one field.

recrit’s picture

"Why should this be more intuitive only for single cases?"
1. The widget settings form states that this is what will happen. (see attached image)
2. If there is only 1 paragraph type then it is acting as the label set for the field widget. This allows re-use of common paragraph types but have them contextually act differently based on the reference field.

miro_dietiker’s picture

Ah i see, we never fully understood this functionality and its needand almost removed it once. We should express its need in specif ic concrete use cases and test cover expectations.

For implementation, i think we should define a getter on the widget.

recrit’s picture

Renrhaf’s picture

miro_dietiker’s picture

Issue tags: +Needs tests

This still needs tests and/or test fixes.

recrit’s picture

geek-merlin’s picture

Category: Feature request » Bug report

I ran into this too. As Miro said, in principle we should be able to use the bundle label. But as that has no plural yet (there is a core issue for that), and that title (singular/plural) setting is already in the widget, it's a bug to not use it so setting as that.
(Sorry i was sleep deprived and confused stuff.)

I noticed this because the bundle label was displayed in the wrong language (which is also a known core issue #3001284: Allow plugin derivers to specify cache tags tags for their definitions).

The patch also needs work as it does not catch all instances of the label. It's at least 3, which you find by grepping 'Add @title'.

geek-merlin’s picture

geek-merlin’s picture

Category: Bug report » Feature request

Correcting my statement above. I'm not convinced anymore that this should do this magic without an explicit configuration option.

fathima.asmat’s picture

Re-rolled #10 to the latest version of 1.15.

fathima.asmat’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 14: paragraphs-single-type-add-button-2884395-14.patch, failed testing. View results