The problem is with a field in the Form, not the submit button, when using AJAX.
I used the changes you made on GitHub, but the difference was adding the name to the submit button, not at the field level, as required.
In my case, the "plan" field when a change is made, should be routed through its "onchange" event to a procedure that receives the value of that field.
I'm sending the script and template for debugging.
In the field's helper attributes, I commented out the "_name" attribute, and when running the script, you can see the result in the "pruajax" action... neither the name of the "plan" field nor its value is sent.
Removing the comment from the attribute fixes it.
CONTEXT:
Windows: 10
Python: 3.12.10 32-bits
Py4Web: 1.20260520.0
SCRIPT:
titulo = 'Planes'
@action("formconajax")
@preferred('basicos/form_titulo.html')
def formconajax():
form = Form([Field('plan', type='integer', length=1, label='Plan',
requires=IS_IN_SET([2, 3, 5, 7], zero=None)),
], dbio=False)
# Obtener helper del campo plan
campo_helper = form.custom.widgets['plan']
# asignar atributos al campo plan
campo_helper.attributes = {
# "_name":"plan",
"_autofocus":True,
"_hx-post": URL("pruajax"),
"_hx-trigger":"change",
"_hx-swap":"none",
}
return {'form':form, 'titulo':titulo}
#-----
# acción ajax
#-----
@action("pruajax")
@preferred()
def pruajax():
print(request.POST)
TEMPLATE: form_titulo.html
[[extend 'layout_super.html']]
[[block center]]
[[=H6(titulo)]]
[[=form]]
[[end]]
P.S.: I'd like to thank you, Massimo, and the entire team that created and supports Py4Web. I've been working with web2py for almost 10 years now, with great success.
Regards from Montevideo, Uruguay.