Skip to content

Latest commit

 

History

History
67 lines (47 loc) · 1.6 KB

File metadata and controls

67 lines (47 loc) · 1.6 KB

ember/template-no-action-on-submit-button

💼 This rule is enabled in the following configs: strict-gjs, strict-gts.

💼 This rule is enabled in the following configs: strict-gjs, strict-gts.

Disallow action attribute on submit buttons.

Using the action attribute on submit buttons is a common mistake. Instead, you should use the {{on}} modifier to handle click events, or handle form submission at the form level.

Rule Details

This rule disallows using the action attribute on <button> elements (which default to type="submit") and <input type="submit"> elements.

Examples

Incorrect ❌

<template>
  <button action="save">Save</button>
</template>
<template>
  <button type="submit" action="submit">Submit</button>
</template>
<template>
  <input type="submit" action="go" />
</template>

Correct ✅

<template>
  <button {{on "click" this.handleClick}}>Save</button>
</template>
<template>
  <button type="button" action="doSomething">Click</button>
</template>
<template>
  <form {{on "submit" this.handleSubmit}}>
    <button type="submit">Submit</button>
  </form>
</template>

Related Rules

References