[Zope] two submit buttons/ one method

John Hunter jdhunter@ace.bsd.uchicago.edu
Thu, 09 May 2002 07:58:21 -0500


>>>>> "Geir" =3D=3D Geir B=E6kholt <geirh@funcom.com> writes:

    Geir> <input type=3D"submit" name=3D"somevar" value=3D"someval" />
    Geir> <input type=3D"submit" name=3D"somevar" value=3D"someotherval" />
    Geir> </form>

Neat idea.  At first I balked because the value is also the text for
the variable, and I wanted one the button's to say something like

'Update Form' with somevar=3D0
'Add event' with somevar=3D1

But I realize that I can process these in the add function, with

if somevar=3D=3D'Update Form':=20
   somevar=3D0
elif somevar=3D=3D'Add Event':
   somevar=3D1
else:
   raise 'Did you change the value of your add form buttons and forget to c=
hange your add function again?'

Not the cleanest design, because if you want to change the text of the
button you have to remember to change your add form, but it should
work.

Thanks,
John Hunter