Skip to content

fix: InputType.HIDDEN no longer renders a visible label (#14) - #28

Open
jannikbx wants to merge 2 commits into
mondi04:mainfrom
jannikbx:fix/hidden-input-signed
Open

fix: InputType.HIDDEN no longer renders a visible label (#14)#28
jannikbx wants to merge 2 commits into
mondi04:mainfrom
jannikbx:fix/hidden-input-signed

Conversation

@jannikbx

Copy link
Copy Markdown

Summary

Fixes #14InputType.HIDDEN form fields no longer render a visible <label> or error <div>. Hidden inputs are now rendered as bare <input type="hidden"> elements.

Commits are GPG signed

Changes

  • htmforge/components/form_field.py: Add early return in render() for InputType.HIDDEN — skips label and error container, returns only the control element
  • tests/test_components.py: Add two new test cases:
    • test_hidden_input_renders_no_label_or_error — verifies bare hidden input without label/error
    • test_hidden_input_with_error_still_no_label — verifies error text is not rendered even when set

Before

field = FormField(name="csrf_token", label_text="CSRF", input_type=InputType.HIDDEN, error="bad")
print(field.to_html())
# → CSRF  ← label and error div visible!

After

field = FormField(name="csrf_token", label_text="CSRF", input_type=InputType.HIDDEN, error="bad")
print(field.to_html())
# → 

Test Results

TestFormField::test_hidden_input_renders_no_label_or_error PASSED
TestFormField::test_hidden_input_with_error_still_no_label PASSED
All 12 FormField tests passing ✅

jannikbx added 2 commits July 27, 2026 00:08
Hidden inputs should render as bare <input type="hidden"> elements
without a <label> or error container, since both are invisible and
meaningless for hidden form fields.

Closes mondi04#14
Hidden inputs should render as bare <input type="hidden"> elements
without a <label> or error container, since both are invisible and
meaningless for hidden form fields.

Closes mondi04#14
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

Successfully merging this pull request may close these issues.

InputType.HIDDEN still renders a visible <label>

1 participant