First stab at a form submit off an alpine.js form. Honestly not great. It's a lot of code already for even less functionality.

This commit is contained in:
Zed A. Shaw 2025-07-27 00:29:27 -04:00
parent e4153fd74a
commit 3fd8169d83
7 changed files with 46 additions and 26 deletions

View file

@ -3,6 +3,8 @@ package admin
import (
"maps"
"strconv"
"fmt"
"reflect"
"github.com/gofiber/fiber/v2"
"zedshaw.games/webapp/data"
. "zedshaw.games/webapp/common"
@ -59,7 +61,14 @@ func GetPageSelectOne(c *fiber.Ctx) error {
}
func PostApiUpdate(c *fiber.Ctx) error {
return c.JSON(fiber.Map{})
user, err := ReceivePost[data.User](c)
if err != nil { return IfErrNil(err, c) }
fmt.Println("post received", user)
err = Update(c.Params("table"), reflect.ValueOf(user).Elem())
if err != nil { return IfErrNil(err, c) }
return c.JSON(fiber.Map{"status": "ok"})
}
func PutApiInsert(c *fiber.Ctx) error {