[Zope] Python, Pre-Fill Form Fields

AdvertisingDept Layne.Bilyeu at robbstucky.net
Mon Feb 23 13:15:11 EST 2004


How do I...
use a python script to pre-fill the value of a form's field?

I am setting a field in the request, 
but it appears in the 'other' section of the request.



Page Template -  html form
-------------------------------
<html>
  <body>
     <form method="POST" action="">
      Enter text: 
      <input name="aformfield" type="text" value="" />
      <input type="submit" name="form.button.submit" value="Submit" />
    </form>
    
    <br /><br /><br />
    <p tal:content="structure request">stuff</p>

  </body>
</html>



Python Script
-------------------------------
#Get the HTML request object
myrequest = container.REQUEST

#preset the request field
myrequest.set('aformfield', 'a value')

#go to the form
return context.theform(REQUEST=myrequest)



Note: I am actually trying to pre-fill a 
CMFformcontroller template in plone 2.0.
However, if I can't get this 
most simple example to work...

Many thanks in advance.



More information about the Zope mailing list