blue-jay / blueprint

Blueprint for your next web application in Go.
https://blue-jay.github.io/
MIT License
482 stars 77 forks source link

how to create new POST submit? #82

Closed albertusg7 closed 4 years ago

albertusg7 commented 4 years ago

Please answer these questions when submitting your issue. Thanks!

  1. Which commit are you using? i think the latest, beacuse i start on dec 2018, https://github.com/blue-jay/blueprint/commit/f200a5c1b49e3560d96c2d71e60cdae7459a7bea

  2. Which operating system, processor architecture, and Go version are you using (go env)? i'm on Windows 7 and 10, intel, and go1.13.5 windows/amd64

  3. What did you do? i'm trying to create a new post like this func Load() { router.Get("/register", Index, acl.DisallowAuth) router.Post("/register", Store, acl.DisallowAuth) router.Get("/register/next", Step3, acl.DisallowAuth) router.Post("/register/next", Step3Store, acl.DisallowAuth) <-- }

on Post "/register" it success and added to my database, and its also success to access the "/register/next" after successed insert the data from "/register"

  1. What did you expect to see? success when insert the data or some error to debuging,

  2. What did you actually see? sometime some panic like this server.go:3056: http: panic serving 127.0.0.1:49508: interface conversion: interface {} is nil, not int64,

but mostly are the button didnt call or do the post function

and after i comment all the code inside the func Step3Store, like below, it still doing nothing

func Step3Store(w http.ResponseWriter, r *http.Request) { c := flight.Context(w, r)

// Get form values
accID_temp := c.Sess.Values["AccountID"].(int64)
fmt.Println(accID_temp)

here's my form and the button for submit

< 1form id="registStep3" class="form-regist" method="post" action="/register/next">

  <input type="hidden" name="accID_temp" value="{{.Account.AccountID}}" />
  <input type="hidden" name="_token" value="{{$.token}}">
  <input type="hidden" name="_method" value="POST">  

aquint-g commented 4 years ago

Could you paste the content of your function : Step3Store() ?

albertusg7 commented 4 years ago

already solved, my mistake are from https://www.w3schools.com/howto/tryit.asp?filename=tryhow_js_form_steps

i comment the submit function. but i have another question, how do we repopulate form for all input? do we call it one by one like this form.Repopulate(r.Form, v.Vars, "investorAddress1","first_name","middle_name","last_name")

or we have some function to call all the inputs? like form.Repopulate(r.Form, v.Vars, all inputs)