grav-plugin-form icon indicating copy to clipboard operation
grav-plugin-form copied to clipboard

Prevent empty label divs

Open hughbris opened this issue 3 years ago • 4 comments

I noticed the logic for showing labels using show_label isn't implemented as early as it should be.

This means when labels aren't being shown, you still get the label wrapper divs rendered, causing problems like asterisks for required fields attached to nothing (empty label divs). Try it with label false and required true on a field.

hughbris avatar Nov 26 '20 23:11 hughbris

I'm seeing is you've moved the label block outside the show_label check. That doesn't change how the internal elements are rendered.

rhukster avatar Dec 01 '20 00:12 rhukster

It allows overriding the label block so the "ghost" label won't render anyway. This is what I have done. (Also I only noticed it because of the red asterisk on it.) I must apologise because I can't remember more about my motivation, however I did find this necessary about 1.5 weeks ago. Too much water under the bridge :) If I remember more, I will add here.

It does seem logical to me that everything label-related is within the label block and I presume it's a harmless mod.

hughbris avatar Dec 02 '20 22:12 hughbris

I need a bit more time to test this especially in regard to the other PR that removes label block entirely from the checkbox field: https://github.com/getgrav/grav-plugin-form/pull/442

rhukster avatar Dec 03 '20 19:12 rhukster

Thanks, understand. My early impression of the other PR is that it wouldn't be needed if this goes in, and this has less likely unintended consequences.

hughbris avatar Dec 03 '20 22:12 hughbris