Updated: Comment #0

Problem/Motivation

The Custom Block entity type's description (info) field is still handled through custom code in entity forms and entity views

Proposed resolution

Move to widgets and formatters.

Remaining tasks

Fix test failures.

User interface changes

None.

API changes

None. The custom_block.info base field is rendered using widgets and formatters, and is no longer exposed as an "extra field".

Comments

wim leers’s picture

Title: Apply formatters and widgets to rendered Custom Block base fields » Apply formatters and widgets to Custom Block base fields
Issue summary: View changes
Status: Active » Needs review
Related issues: +#2111887: Regression: Only title (of base fields) on nodes is marked as translatable
StatusFileSize
new2.53 KB
wim leers’s picture

Issue tags: +Novice

Status: Needs review » Needs work

The last submitted patch, 1: block_base_fields_configurable-2225371-1.patch, failed testing.

mr.baileys’s picture

Assigned: Unassigned » mr.baileys

Working on this during the Szeged sprint.

wim leers’s picture

Note: this is still missing a setRequired() call, like I added over at #2225399-2: Apply formatters and widgets to Feed base fields. You may want to add that too, mr.baileys.

mr.baileys’s picture

StatusFileSize
new15.11 KB
new13.18 KB

Test failures fixed.

Since the property keys returned by CustomBlockTranslationUITest::getNewEntityValues() are used to build the edit-array for form posts (getEditValues()) as well as for entity creation (ContentTranslationTestBase::createEntity()), and since the property name to use in both cases differs ('info' for entity creation, 'info[0][value]' for form posting), I had to hack-by-overriding getEditValues() to ensure the correct property name is used.

mr.baileys’s picture

Status: Needs work » Needs review
StatusFileSize
new15.14 KB
new13.92 KB

Added the setRequired-call mentioned in #5.

yanniboi’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new36.52 KB
new41.3 KB

I have had a look at this.

Installing with minimal and standard profiles works, creating a custom block works and editing works.

Compared the form display settings before and after patch.

before patch

after patch

Also configuring the block description works fine.

Looks like this is RTBC

wim leers’s picture

Issue summary: View changes

Updating issue summary as per yched's instructions at #2225431-4: Apply formatters and widgets to Taxonomy Term base fields.

Thanks for the review, yanniboi!

wim leers’s picture

Status: Reviewed & tested by the community » Needs work
StatusFileSize
new12.13 KB

I manually tested the patch also, and I found one big problem: it causes block descriptions to be rendered:

+++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Entity/CustomBlock.php
@@ -175,8 +175,19 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
+      ->setDisplayOptions('view', array(
+        'label' => 'hidden',
+        'type' => 'string',
+        'weight' => -5,
+      ))

This should be removed. Then the block description won't be rendered.

mr.baileys’s picture

Status: Needs work » Needs review
StatusFileSize
new15 KB
new840 bytes

Removed view display options from description as per #10

k.dani’s picture

Status: Needs review » Reviewed & tested by the community

I have applied the patch against the *current* HEAD of 8.x branch without any problems. The Block description isn't rendered and the configuration works fine for me. The only problem I noticed is the following:

If I place a custom block into a region, I will get the following warning: "Theme hook custom_block not found.". I couldn't find the implementation of "custom_block" theme. May it be missing?

Anyway, it seems to me that this problem is not related to the issue and the patch, so I change the status of it to RTBC.

galooph’s picture

StatusFileSize
new9.15 KB

Just tested this manually and it works as expected. The block description is no longer rendered.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs reroll

2225371-10-custom-block-base-fields_1.patch no longer applies.

error: patch failed: core/modules/block/custom_block/lib/Drupal/custom_block/Entity/CustomBlock.php:175
error: core/modules/block/custom_block/lib/Drupal/custom_block/Entity/CustomBlock.php: patch does not apply

mr.baileys’s picture

Status: Needs work » Needs review
StatusFileSize
new15.06 KB

Straight re-roll to keep up with HEAD.

galooph’s picture

Patch from #15 applied cleanly and worked fine. The block description was not rendered.

mr.baileys’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Novice, -Needs reroll

Ok, since this was a straight re-roll and the tests came back green, back to RTBC.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs reroll

2225371-15-custom-block-base-fields.patch no longer applies.

error: patch failed: core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockTypeTest.php:178
error: core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockTypeTest.php: patch does not apply

mr.baileys’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll +Avoid commit conflicts
StatusFileSize
new15.02 KB

Straight re-roll. (Wim Leers told me to add "Avoid commit conflicts").

pfrenssen’s picture

Issue summary: View changes
pfrenssen’s picture

Status: Needs review » Reviewed & tested by the community

Looking good! Back to RTBC.

catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 8.x, thanks!

  • Commit 8f028bb on 8.x by catch:
    Issue #2225371 by mr.baileys, Wim Leers: Apply formatters and widgets to...
wim leers’s picture

Issue tags: -sprint

Status: Fixed » Closed (fixed)

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