Ember Form Submission without controller

Hi

I am new to ember and I am looking for a way to submit my form without the help of controllers because all the example I find on internet uses controllers for example a fiddle showing this : Ember Latest - JSFiddle - Code Playground

Can you actualy help in form submission.

Actions should bubble up to your routes if you are in a top level template.

Example:

Ember.Route.extend({
  actions: {
    submission() {
      console.log("handle form submission");
    }
  }
})

form:

<form {{action "submission" on="submit"}}>
  <button type="submit">Submit</button>
</form>

I hope this helps!

Ben

There is also the route-action-helper: GitHub - DockYard/ember-route-action-helper: Bubble closure actions in routes

It’s probably a touch controversial but right now I am continuing to use controllers. Yes, they will be removed at some point but I don’t see that happening for a long time given how embedded they are in pretty much every app/addon.

I think that avoiding using them now actually feels more hacky and prone to issues than just doing things the “old way” and migrating at a later date if/when controllers are actually fully removed.

It doesn’t feel like removing controllers is a priority for the Ember team (and I agree with them) and trying to eliminate them is a lot of work and sometimes requires some very smelly code IMO.

1 Like

See they might remove or not remove them but Since there spec says that it should not be used whenever creating a new app I should avoid them.

Using them now is like adding to already existing problem of many app/add-on using them.

Thanks

Not controversial at all. In fact, this is why they’re still around and the engineers making assumptions on what the future holds aren’t doing themselves a service.

I’d disagree for a few reasons:

  • Avoiding controllers is actually a lot of extra work right now
  • It rules out using some of the best Ember add-ons
  • If controllers are ever deprecated then there will be official guideliness on how to migrate from them which will most likely lead to better code than what you would have if you just try to avoid using them now.