In ColorBackgroudFormatter.php #attached uses css to add css to an element, but this is no more supported.

foreach ($items as $delta => $item) {
      $elements[$delta] = array(
        '#type' => 'html_tag',
        '#tag' => 'p',
        '#value' => t('The content area color has been changed to @code', array('@code' => $item->value)),
        '#attached' => array(
          'css' => array(
            array(
              'data' => 'main { background-color:' . $item->value . ';}',
              'type' => 'inline',
            ),
          ),
        ),
      );
    }
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jeevanbhushetty created an issue. See original summary.

jeevanbhushetty’s picture

Assigned: jeevanbhushetty » Unassigned
Status: Active » Needs review
FileSize
962 bytes
AjitS’s picture

Status: Needs review » Reviewed & tested by the community

Nice catch! The patch solves the issue quite elegantly.
RTBC from my side.

Mile23’s picture

Priority: Major » Critical
Status: Reviewed & tested by the community » Fixed

I'm going to commit this because it's really a critical: D8 throws an unhandled exception meaning things stop working.

I'm a bit gobsmacked that we don't have a test for ColorBackgroudFormatter, because that would have found this flaw. We need to add that, but it can be a follow-up since this is actually critical.

Here's the follow-up: #2720833: Add a functional test for field_example ColorBackgroudFormatter

Thanks, folks!

jeevanbhushetty’s picture

Thanks @Miles23, I am working on test case for ColorBackgroundFormatter, we already have issues created for this #2634034: Create a regression test for ColorBackgroudFormatter so closing #2720833: Add a functional test for field_example ColorBackgroudFormatter as duplicate.

Status: Fixed » Closed (fixed)

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