grav-plugin-form
grav-plugin-form copied to clipboard
Prevent empty label divs
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.
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.
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.
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
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.