html icon indicating copy to clipboard operation
html copied to clipboard

Fieldset should support readonly attribute

Open pfteter opened this issue 1 year ago • 0 comments

What problem are you trying to solve?

Fieldset supports the disabled attribute. Setting the disabled attribute disables automatically all it's children.

<fieldset disabled>
    <legend>Choose your favorite monster</legend>
    <input type="radio" id="kraken" name="monster" value="K" />
    <label for="kraken">Kraken</label><br />
  </fieldset>

Demo

this is a useful Feature when creating a form manager together with form association.

The form controls support the readonly attribute too, it would make sense to propagate the readonly attribute from the fieldset controls as it's done with the disabled attribute.

Use Case: In a form disable a whole part of a form or make it readonly

<fieldset readonly>
    <legend>Choose your favorite monster</legend>
    <input type="text" id="kraken" name="monster" value="Readonly value" />
    <label for="kraken">Kraken</label><br />
  </fieldset>

What solutions exist today?

Setting disabled on a fieldset automatically disables all controls that support it. A very similar attribute readonly needs to be set manually on all controls.

How would you solve it?

Add support for the readonly attribute on fieldset that would work in a similar way as disabled - propagate readonly to all its children

Anything else?

Only concern is not all controls support readonly, but neither do all html elements disabled. This would make sense to use for web components that have form association implemented to be handled through a form manager - for example dynamic forms / form builder.

pfteter avatar Apr 23 '24 08:04 pfteter