Fieldset is a container for grouping related form elements. It includes fieldset-legend as a title and label as a description.
Base Fieldset
Exported source
fieldset = SingleValueFactory("fieldset", "Base fieldset component for the fieldset container") # Base fieldset componentlabel = SingleValueFactory("label", "Base label component for inputs") # Base label componentfieldset_legend = SingleValueFactory("fieldset-legend", "fieldset legend part for the title of the fieldset") # fieldset legend part
Fieldset Test Examples
test_fieldset_basic_examples
def test_fieldset_basic_examples():
Test basic fieldset utilities.
Exported source
def test_fieldset_basic_examples():"""Test basic fieldset utilities."""# Basic fieldsetassertstr(fieldset) =="fieldset"assertstr(label) =="label"assertstr(fieldset_legend) =="fieldset-legend"# Test with modifiersassertstr(fieldset.hover) =="hover:fieldset"assertstr(fieldset.md) =="md:fieldset"assertstr(fieldset.dark) =="dark:fieldset"assertstr(label.hover) =="hover:label"assertstr(label.md) =="md:label"assertstr(label.dark) =="dark:label"assertstr(fieldset_legend.hover) =="hover:fieldset-legend"assertstr(fieldset_legend.md) =="md:fieldset-legend"assertstr(fieldset_legend.dark) =="dark:fieldset-legend"# Run the teststest_fieldset_basic_examples()
test_fieldset_basic_fasthtml_examples
def test_fieldset_basic_fasthtml_examples():
Test basic fieldset with legend and label from daisyUI v5 documentation.
Exported source
def test_fieldset_basic_fasthtml_examples():"""Test basic fieldset with legend and label from daisyUI v5 documentation."""from fasthtml.common import Fieldset, Legend, Input, Pfrom cjm_fasthtml_daisyui.components.data_input.text_input import text_input# Fieldset with legend and label basic_fieldset = Fieldset( Legend("Page title", cls=str(fieldset_legend)), Input(type="text", placeholder="My awesome page", cls=str(text_input)), P("You can edit page title later on from settings", cls=str(label)), cls=str(fieldset) )# Verify structureassert basic_fieldset.tag =="fieldset"assert basic_fieldset.attrs['class'] =="fieldset"# Verify legend legend_element = basic_fieldset.children[0]assert legend_element.tag =="legend"assert legend_element.attrs['class'] =="fieldset-legend"assert legend_element.children[0] =="Page title"# Verify input input_element = basic_fieldset.children[1]assert input_element.tag =="input"assert input_element.attrs['type'] =="text"assert input_element.attrs['placeholder'] =="My awesome page"assert input_element.attrs['class'] =="input"# Verify label label_element = basic_fieldset.children[2]assert label_element.tag =="p"assert label_element.attrs['class'] =="label"assert label_element.children[0] =="You can edit page title later on from settings"return basic_fieldset# Run the teststest_fieldset_basic_fasthtml_examples()