diff --git a/controllers/threads_controller.go b/controllers/threads_controller.go index bf22c76..d1aa8bb 100644 --- a/controllers/threads_controller.go +++ b/controllers/threads_controller.go @@ -262,6 +262,10 @@ func UpdateThread(c *fiber.Ctx) error { CaptchaID: captchaID, IsCaptchaActive: config.App.IsCaptchaActive, Errors: *validationErrors, + Inputs: repositories.Inputs{ + Text: text, + Files: filesInRequest, + }, }, } diff --git a/repositories/structs.go b/repositories/structs.go index 7f805a9..5493ed2 100644 --- a/repositories/structs.go +++ b/repositories/structs.go @@ -1,6 +1,9 @@ package repositories -import "time" +import ( + "mime/multipart" + "time" +) // DB Structs // DB Structs @@ -40,18 +43,23 @@ type File struct { // HTML Templates Structs // post-form.html -type Inputs struct { +type Errors struct { Title string Text string Files string } +type Inputs struct { + Title string + Text string + Files []*multipart.FileHeader +} // post-form.html type HtmlFormData struct { FirstPostID int CaptchaID string IsCaptchaActive bool - Errors Inputs + Errors Inputs } diff --git a/templates/components/post-form.html b/templates/components/post-form.html index 78c190d..2562dcb 100644 --- a/templates/components/post-form.html +++ b/templates/components/post-form.html @@ -10,13 +10,13 @@ {{ if eq .FirstPostID 0 }} - + {{ end }} - + - + {{ if .IsCaptchaActive }} {{ template "captcha" .CaptchaID }} diff --git a/utils/utils.go b/utils/utils.go index 4a573f2..32b39c3 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -101,8 +101,8 @@ func ValidatePost(title, text string, files []*multipart.FileHeader) string { return "" } -func ValidatePost2(title, text string, files []*multipart.FileHeader) *repositories.Inputs { - validationErrors := new(repositories.Inputs) +func ValidatePost2(title, text string, files []*multipart.FileHeader) *repositories.Errors { + validationErrors := repositories.Errors{} hasErrors := false if text == "" && len(files) == 0 { @@ -139,7 +139,7 @@ func ValidatePost2(title, text string, files []*multipart.FileHeader) *repositor } if hasErrors { - return validationErrors + return &validationErrors } return nil