Reputation: 1771
I'm new to Sails, so I may be doing this wrong, but I can't seem to get data from my form in the controller.
The submit action routes to the proper controller method.
<form action="/create" method="POST">
<div class="form-group">
<label for="title">Title</label>
<input type="text" class="form-control" id="title">
</div>
<button type="submit" class="btn btn-default">Submit</button>
</form>
Controller action:
save: function (req, res) {
console.log(req.param('title'));
console.log(req.params.all());
}
Results in:
undefined
{}
How am I supposed to get the submitted form data?
Upvotes: 1
Views: 526
Reputation: 1456
It seems that you omit the name attribute.
<label for="title">Title</label>
<input type="text" class="form-control" id="title" name="title">
Without this the parameter can't be received from the server.
Upvotes: 4