Fieldset is a component to aid in creating form components that require an underlying <fieldset>
and <legend>
. It is similar to Field, in that it provides an opinionated shell for building other components such as checkbox groups and radio groups.
Provide a string to @label
to render the text into the <legend>
of the Fieldset. This is required.
Optional. Provide a string to @hint
to render the text into the Hint section of the Fieldset.
Optional. Provide a string or array of strings to @error
to render the text into the Error section of the Fieldset.
Set the @isDisabled
argument to disable the fieldset. When disabled, all form controls that are descendants of the fieldset, are disabled, meaning they are not editable and won't be submitted along with the form. Learn more via the fieldset documentation.
Consumers have direct access to the underlying fieldset element, so all attributes are supported.
The wrapping element is a <fieldset>
and attributes are spread directly on it as mentioned above. Due to that, one can target the fieldset with any data attribute.
Target the label element via data-label
.
Target the hint block via data-hint
.
The yield
is wrapped in a div container that can be targeted with data-control
.
Target the error block via data-error
.
~Fieldset components render here!~
<Form::Fieldset @label='Label' @hint="With hint text">
~Fieldset components render here!~
<Form::Fieldset @label='Label' @error="With error">
~Fieldset components render here!~
<Form::Fieldset @label='Label' @hint="With hint text" @error="With error">
~Fieldset components render here!~
<Form::Fieldset @label='Label' @hint="With hint text" @error={{(array "With error 1" "With error 2" "With error 3")}}>
~Fieldset components render here!~