For improving the backend UX of Paragraphs forms, we tend use specific theming for the forms.
It would help a lot of the draggable rows contain the paragraphs type (bundle) as a class.
That's also in line with the usual content type class added to the node form.

Patch will follow

Comments

rv0’s picture

Issue summary: View changes
Status: Active » Needs review
StatusFileSize
new426 bytes

This patch add paragraphs-item-type-bundle-name as a class to the draggable rows.
The name is "inspired" by the node-type-bundle-name class drupal adds to the body of a node form

  • jeroen.b committed 20d26ce on 7.x-1.x authored by rv0
    Issue #2542066 by rv0: Add paragraphs bundle class to row in backend
    
jeroen.b’s picture

Status: Needs review » Fixed

Thanks, pushed to dev!

Status: Fixed » Closed (fixed)

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

postovan dumitru’s picture

I get the following error when editing/creating a node and saving it afterwards:
Notice: Undefined index: #bundle in theme_paragraphs_field_multiple_value_form() (line 1170 of */sites/all/modules/contrib/paragraphs/paragraphs.module).

I have a complex structure with a field paragraph, containing a wrapper paragraph with custom class and ID fields and another paragraph field(which contains the paragraphs with the content).

Could we add a check for $item['#bundle'] in :

$rows[] = array(
        'data' => $cells,
        'class' => array('draggable', drupal_html_class('paragraphs_item_type_' . $item['#bundle'])),
      );
postovan dumitru’s picture

StatusFileSize
new535 bytes

Attaching patch with the suggested change.

demonde’s picture

While this feature is implemented in Drupal 7, it is missing in Drupal 8.

chrisdarke’s picture

StatusFileSize
new1.17 KB
new572 bytes

As of PHP 7.1.0, applying the empty index operator on a string throws a fatal error. This means setting the class array to an empty string throws an error. This patch includes a fix for that. Thanks to @oadaeh for identifying that.

firewaller’s picture

I was about to re-open this, but found the referenced issue for the followup patch. Just wanted to add it here so nobody else gets confused: https://www.drupal.org/project/paragraphs/issues/3010369