Emerson / ember-form-master-2000

A simple form builder for Ember built as an Ember-CLI addon.
MIT License
40 stars 18 forks source link

Change submit tagName to button #16

Closed srsgores closed 9 years ago

srsgores commented 9 years ago

The current implementation of <input type="submit"/> is bad because it reduces accessibility in some screen readers. Furthermore, the button attribute should be used in favour of HTML5. Finally, the input element is misleading in that it is not a "modifiable" control; it merely serves one purpose, and that is to trigger the submit action.

This change allows the user to pass in extra content into a button (such as an icon):

{{#fm-submit value="Let's go"}}{{custom-icon icon="user" title="My nested icon content"}}{{/fm-submit}}
srsgores commented 9 years ago

Thanks for merging. It looks like we're also not allowing the user to pass in title, so I think that may deserve a or as well

Emerson commented 9 years ago

agreed, there is probably a list of standard attributes that need to be added to every element... just need to figure out what that list is.

srsgores commented 9 years ago

@Emerson, actually, an easier fix would be to set tagName to "button" instead of "div". Then, all you would need to do is attributeBindings: ["title", "disabled", "role"]. Want me to make another PR?

Emerson commented 9 years ago

I think the submit is auto wrapped in a div tag with the standard wrapper class to keep things consistent with the rest of the fields (all of which are wrapped). I think I'd prefer to move towards something like:

{{fm-submit}} => no wrapper div

and

{{fm-field type="submit"}} => has the standard wrapper div

Any thoughts on that? It would allow us change the tagName, but still requires dealing with data attributes passed through the field.