4

I was wondering if it's somehow possible to remove the wrapper div from Rails hidden inputs that are automatically generated on forms?

The reason is that it's giving me a 'B' on my ySlow report and telling me to avoid CSS expressions. I know this small thing really doesn't matter for performance, but I would like to know if it's possible.

Grade B on Avoid CSS expressions
There is a total of 1 expression
inline <style> tag #1 (1 expression)

<form accept-charset="UTF-8" action="/site/search" method="get">
  <div style="margin:0;padding:0;display:inline">
    <input name="utf8" type="hidden" value="&#x2713;" />
  </div
...
anthony
  • 391
  • 1
  • 3
  • 15

2 Answers2

1

The surrounding div-tag has been removed in Rails 4.2

cantonic
  • 1,033
  • 7
  • 12
0

From the guide on form helper

This div is important, because the form cannot be successfully submitted without it. The first input element with name utf8 enforces browsers to properly respect your form’s character encoding and is generated for all forms whether their actions are “GET” or “POST”.

If you remove it the form won't act properly.

By the way, the so called CSS inline is for main style. YSlow is just a tool, used by human being. If there is something you have to do, just do it.

Billy Chan
  • 24,625
  • 4
  • 52
  • 68