# Improve semantics of orphaned form elements such as buttons

**URL:** <https://meta.discourse.org/t/improve-semantics-of-orphaned-form-elements-such-as-buttons/72936>\
**Category:** UX\
**Created:** [Outubro 27, 2017, 4:41pm UTC](https://meta.discourse.org/t/improve-semantics-of-orphaned-form-elements-such-as-buttons/72936 "2017-10-27T16:41:21Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![jxpx777](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jxpx777/32/120595_2.png) [@jxpx777](https://meta.discourse.org/u/jxpx777)\
**Post date:** [Outubro 27, 2017, 4:41pm UTC](https://meta.discourse.org/t/improve-semantics-of-orphaned-form-elements-such-as-buttons/72936/1 "2017-10-27T16:41:21Z")

</div>

Disclosure: I work for AgileBits, makers of 1Password.

I was diagnosing an issue with 1Password failing to offer to save user’s credentials when clicking the “Log In” button in the modal sign in dialog. The main issue turned out to be that the “Log In” `<button>` is not a child of the `<form>` that it controls and does not have a `form` attribute set. With these kinds of orphaned elements, 1Password is much more reserved about its interpretation of the user’s clicks.

I arrived at a solution that will work around this in the 1Password extension, but it would be more semantic if Discourse’s buttons were either children of their `<form>` elements or had explicit relationship set up via the `form` attribute.

It would also be appropriate to explicitly set the `type` attribute of this button to “submit”. Even though this is the default attribute value, apps like 1Password look for an explicit attribute because lots of sites use buttons with no type attribute for things that do not have a submit behavior.

I got as far as tracking this down to [login.hbs:43](https://github.com/discourse/discourse/blob/master/app/assets/javascripts/discourse/templates/modal/login.hbs#L43) and was going to make a PR to add the `form="login-form"` attribute, but had some issues getting the dev environment set up and ran out of time so I punted to creating a bug report. ☹

Thanks!

–  
Jamie Phelps  
Code Wrangler @ AgileBits  
Fort Worth, Texas

---

_[View the full topic](https://meta.discourse.org/t/improve-semantics-of-orphaned-form-elements-such-as-buttons/72936)._
