Whenever a form with a honeypot is loaded, I get an error page, and the following exception is logged:

Uncaught PHP Exception LogicException: "You are not allowed to use css in #attached" at /var/www/drupal/core/includes/common.inc line 1719

The offending code inside honeypot.module (in honeypot_add_form_protection() is:

      // Hide honeypot.
      '#attached' => [
        'css' => [
          '.' . $honeypot_class . ' { display: none !important; }' => ['type' => 'inline'],
        ],
      ],

Since there was a recent commit that removed the ability to attach dynamically-generated CSS and JS using #attached, we might have to architect a new solution or go back to the D6 method of having a static (and more easily bot-defeatable) class for the honeypot form. See my comments in #2391025: Add support for inline JS/CSS with #attached.

Until then, Honeypot is broken on D8 HEAD.

CommentFileSizeAuthor
#3 dynamic_css_in_form-2403753-3.patch886 bytesgeerlingguy
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

geerlingguy’s picture

Issue summary: View changes
geerlingguy’s picture

The following code may work... testing:

    // Hide honeypot.
    $form[$honeypot_element]['#attached']['html_head'][] = [[
      '#tag' => 'style',
      '#value' => '.' . $honeypot_class . ' { display: none !important; }',
    ], 'honeypot_css'];
geerlingguy’s picture

Assigned: Unassigned » geerlingguy
FileSize
886 bytes
geerlingguy’s picture

Status: Active » Needs review

  • geerlingguy committed e3da582 on 8.x-1.x
    Issue #2403753 by geerlingguy: Dynamic CSS in form results in...
geerlingguy’s picture

Status: Needs review » Fixed

Fixed.

  • geerlingguy committed c1f88bd on 8.x-1.x
    Issue #2403753 by geerlingguy: Fix the module name for the attached head...

Status: Fixed » Needs work

The last submitted patch, 3: dynamic_css_in_form-2403753-3.patch, failed testing.

geerlingguy’s picture

Status: Needs work » Fixed

Silly testbot.

Status: Fixed » Closed (fixed)

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