Reputation: 11
I define a struct in beego and add form tag to realtive fields, and the input type="datetime-local" in html
struct code:
type TaskModifyForm struct {
ID int `form:"id"`
Name string `form:"name"`
Status string `form:"status"`
Content string `form:"content"`
UserCode string `form:"user_code"`
StartTime *time.Time `form:"start_time"`
CompleteTime *time.Time `form:"complete_time"`
DeadlineTime *time.Time `form:"deadline_time"`
}
html code:
<div class="d-inline-flex row m-2">
<label class="form-label col-4" for="completetime">end time</label>
<div class="col-8">
<input class="form-control form-control-sm" type="datetime-local" id="deadlinetime" name="deadline_time" value="{{ datetimeFormat2 .task.DeadlineTime }}"/>
</div>
</div>
beego controller code:
func (c *TaskController) Modify() {
form := new(forms.TaskModifyForm)
task := new(models.Task)
errs := errors.New()
if c.Ctx.Input.IsPost() {
//post请求
err := c.ParseForm(form)
if err != nil {
log.Fatal(err)
}
}
I have tried many times, but it still doesn't work, any advice will be great appreciated!
Upvotes: 1
Views: 65