processwire-issues icon indicating copy to clipboard operation
processwire-issues copied to clipboard

InputfieldWrapper label has empty "for"

Open hiboudev opened this issue 1 year ago • 0 comments

Short description of the issue

When adding a label to an InputfieldWrapper, the "for=" is empty. When I hover the form, Firefox shows a warning in console: Empty string passed to getElementById().

I see that wrapper is a <li>, so there's no input to target in label.for, so maybe the wrapper label should be a div?

Expected behavior

Label should target the corresponding wrapper.

Steps to reproduce the issue

$form = new InputfieldForm();

$roundWrapper = (new InputfieldWrapper())
    ->attr('id', "wrapper")
    ->label("wrapper");

$input = (new InputfieldSelect())
    ->attr('id', "input")
    ->label("select");

$form->add($roundWrapper);
$roundWrapper->add($input);
echo $form->render();

HTML of the wrapper label: <label class='InputfieldHeader ui-widget-header' for=''>

Setup/Environment

  • ProcessWire version: 3.0.240

hiboudev avatar Aug 09 '24 10:08 hiboudev