Open gedw99 opened 9 months ago
you actually can without any change 😄 .
short example it your template you would do something like this :
myform.gohtml
<form class="space-y-6" hx-put="/config" hx-target=".element-form-container" hx-ext="json-enc-nested,notify">
{{ form_render .Data.Form .Data.Errors "Loc" .Loc }}
<div class="flex items-center justify-between">
<button type="submit" class="inline-flex items-center rounded-md bg-orange-500 dark:bg-indigo-600 px-3 py-2 text-sm font-semibold text-white shadow-sm hover:bg-orange-700 ">Update Form</button>
</div>
</form>
as you can see here, we can put all the hx attributes on the form element.
on the receiving end, in this case the put:config route we can validate and either respond with an hx-redirect
or return the form/template with or without the errors.
I'm a bit in doubt on where to place the full example as i don't want to create dependances between the two packages.
hey @donseba
you actually can without any change 😄 .
short example it your template you would do something like this :
myform.gohtml
<form class="space-y-6" hx-put="/config" hx-target=".element-form-container" hx-ext="json-enc-nested,notify"> {{ form_render .Data.Form .Data.Errors "Loc" .Loc }} <div class="flex items-center justify-between"> <button type="submit" class="inline-flex items-center rounded-md bg-orange-500 dark:bg-indigo-600 px-3 py-2 text-sm font-semibold text-white shadow-sm hover:bg-orange-700 ">Update Form</button> </div> </form>
as you can see here, we can put all the hx attributes on the form element.
on the receiving end, in this case the put:config route we can validate and either respond with an
hx-redirect
or return the form/template with or without the errors.I'm a bit in doubt on where to place the full example as i don't want to create dependances between the two packages.
I see what you mean. So how about we make a repo called "demo", that has a go.work for each sub repo then ? Then there is no coupling and we have a place to build up demos where we are still enforcing this decoupling.
I actually use this pattern all the time. Here is what a Makefile looks like that wants a repo and to ensure it's an "island". go.work is a god send....
git clone https://github.com/donseba/go-form
@echo go-form >> .gitignore
touch go.work
go work use ./go-form
with https://github.com/donseba/go-htmx