[ZPT] Re: Action

Martijn Pieters mj@zope.com
Wed, 19 Mar 2003 11:20:45 -0500


On Wed, Mar 19, 2003 at 04:52:29PM +0100, Tom Deprez wrote:
> Something like this:
> 
> ----
> <form action="employeeHandlers">
> 
> <p>Select one or more employees</p>
> 
> <input type="checkbox" name="employees:list" value="Larry"> Larry<br>
> <input type="checkbox" name="employees:list" value="Simon"> Simon<br>
> <input type="checkbox" name="employees:list" value="Rene"> Rene<br>
> 
> <input type="submit" name="fireEmployees:action"
> value="Fire!"><br>
> 
> <input type="submit" name="promoteEmployees:action"
> value="Promote!">
> 
> </form>
> ---
> 
> Depending on the submit button another pythonscript is called. At the
> moment, I give that input type a name="action" and depending on the value of
> 'action' I decide which python script to perform. But perhaps there was a
> better one, like we could do in DTML (as above)

Do you know about the :method modifier? It does exactly that; it'll find a
method named by the submitted form field ending in :method starting at the
form action.

-- 
Martijn Pieters
| Software Engineer  mailto:mj@zope.com
| Zope Corporation   http://www.zope.com/
| Creators of Zope   http://www.zope.org/
---------------------------------------------