我有一個帶有動態輸入數量的html表單。每個輸入必須是一個Model對象,並且我還有一個函數,它接收來自這個輸入的值。 我的HTML表單:如何使用Revel Golang處理來自HTML表單的動態輸入數字
<form action="{{url "Votes.CreateVote"}}" id="formVoteCreate" method="POST">
<p class="field">
<label>Question:</label>
<input type="text" name="question" size="40" />
</p>
<div ng-repeat="answer in answers">
<p class="field">
<label>//stuff.title//:</label>
<input type="text" name=//stuff.name// size="40" />
</p>
</div>
<p>
<input ng-click="addInput()" class="btn" type="button" value="Add answer">
</p>
<p class="buttons">
<input class="btn" type="submit" value="Create" />
</p>
</form>
陶醉golang處理程序:
func (c Votes) CreateVote() revel.Result {
// in this place i want get a slice with answers from html form
return c.Redirect(routes.App.Index())
}
和答案型號:
type Answer struct {
Model
Text string
}
如何發送形式的價值觀與包裝,以標準答案分得一杯羹?