从url中检索:id并将其用作表单值
我试图得到它,以便当用户去/checkout
,他们可以input一个数字和用户然后保存它。 我的问题是,所以当他们在查看所有/显示页面,他们点击checkout
,并把他们到/checkout/:id
。 我得到了这个很容易的部分,但是如何从模板中的URL访问该ID?
这是我的forms:
<form role="form-inline"action="/dashboard/it/expendable/checkout?_method=PUT" method="POST"> <div class="form-group col-md-4"> <label for="name" class="control-label">Number of units checked out</label> <input type="number" class="form-control" id="name" name="checkoutNum" placeholder="# Units"> </div><!-- Number Checkout --> </form>
我的路线:
// checkout expendable app.get('/dashboard/it/expendable/checkout/:id', setRedirect({auth: '/login'}), isAuthenticated, (req, res, next) => { next(); }, setRender('dashboard/it/checkoutExpendable'), dashboard.getDefault);
我需要来自URL的ID能够被传递到我的PUT
路由来主要保存数据的单位数量。 我打算这样做,它创build一个新的检出document
然后更新现有document
的消耗量。