Skip to content

fix(Form): support setting the name attribute#6539

Merged
benjamincanac merged 1 commit into
v4from
feat/form-name-attribute
Jun 3, 2026
Merged

fix(Form): support setting the name attribute#6539
benjamincanac merged 1 commit into
v4from
feat/form-name-attribute

Conversation

@benjamincanac
Copy link
Copy Markdown
Member

@benjamincanac benjamincanac commented Jun 2, 2026

🔗 Linked issue

Resolves #5983

❓ Type of change

  • 📖 Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

The name prop was reserved for nested-form state paths, and the native name attribute was stripped via Omit<FormHTMLAttributes, 'name'>, so there was no way to set a name on the rendered <form> element. This blocks use cases like Netlify Forms, which require a name attribute matching a form-name input.

name is now typed string (instead of nested-only) and bound explicitly to the root <form>. It still acts as the state path for nested forms (which render a div), so the dual behaviour is preserved:

  • root form → renders as the <form name="..."> attribute
  • nested form → used as the path of the form's state within its parent

Added renderEach coverage for name (plus method, id, class, ui, and aria-label).

📝 Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

The `name` prop was reserved for nested-form state paths and the native `name` attribute was stripped, so it couldn't be set on the rendered `<form>` element (needed for e.g. Netlify Forms). It now renders as the form's `name` attribute on root forms while still acting as the state path for nested forms.

Resolves #5983
@benjamincanac benjamincanac changed the title feat(Form): support setting the name attribute fix(Form): support setting the name attribute Jun 2, 2026
@benjamincanac benjamincanac requested a review from romhml June 2, 2026 13:12
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 2, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

This PR makes the UForm component's name prop unconditionally available so users can set form names for Netlify Forms and other integrations. Previously, the prop was only typed for nested forms. The name prop type signature was updated from conditional to always-available optional string. The template binding now conditionally sets the attribute to undefined when a parent bus exists (nested context) and uses props.name otherwise, preserving nested form validation. Test coverage was expanded with additional render cases covering various prop combinations.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: enabling support for setting the name attribute on the Form component.
Linked Issues check ✅ Passed The PR successfully addresses issue #5983 by enabling the name attribute on UForm while preserving nested-form behavior, matching all stated objectives.
Out of Scope Changes check ✅ Passed All changes are directly scoped to the linked issue: updating the name prop typing, adjusting template binding, and adding test coverage for the new functionality.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description check ✅ Passed The PR description clearly relates to the changeset, explaining the motivation and implementation of supporting the name attribute on the form element.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/form-name-attribute

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Jun 2, 2026

npm i https://pkg.pr.new/@nuxt/ui@6539

commit: 1408f3a

@benjamincanac benjamincanac merged commit f8186e2 into v4 Jun 3, 2026
24 checks passed
@benjamincanac benjamincanac deleted the feat/form-name-attribute branch June 3, 2026 12:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

v4 #4488

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow setting the form's name attribute on UForm

1 participant