Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accessing fieldset and legend for radio buttons #20

Open
weierophinney opened this issue Dec 31, 2019 · 1 comment
Open

Accessing fieldset and legend for radio buttons #20

weierophinney opened this issue Dec 31, 2019 · 1 comment

Comments

@weierophinney
Copy link
Member

An element's label can get attributes, e.g. class. Theoretically this behavior is also possible for radio buttons. But the setLabelAttributes(['class' => 'my_class']) called on a Zend\Form\Element\Radio object sets the attribute(-s) for the input elements and not for the container-element.

And it's not possible to access the fieldset or the legend element, that are "hard-coded" in the Zend\Form\View\Helper\FormRow. (Also the maintaining of a custom view helper for the 135 rows long FormRow#render(...) is not easy.)

It would be nice to be able to set the fieldset's and legend's attributes of radio buttons / multi_checkbox'es (and generally of all elements, affected by this code).

An example of a situation, when it's need, is makring elements as required using the :before CSS pseudo-class. For text fields it can be managed by setting the class attribute for the label. For radio's an access to the fieldset and/or at least to the legend is needed.


Originally posted by @automatix at zendframework/zend-form#129

@weierophinney
Copy link
Member Author

There appears to be no way to add attributes, such as an id to the generated fieldset that gets created for Element\Radio button, when ['options']['label'] value is used. I can add attributes to the individual <label> tags, or to the individual <input> tags, but not to the enveloping <fieldset> tag.
Currently, I used CSS selectors/pseudo-classes to get around this issue.


Originally posted by @dennis-fedco at zendframework/zend-form#129 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant