Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to modify a z3c form field in updateWidgets?
    primarykey
    data
    text
    <p>I am trying to dynamically update a form field based on a variable that is included in a HTTP get variable. Specifically www.site.com/form?id=name. I want to pull the 'id' field from the url and automatically populate the memberID field of the form.</p> <p>I have access to the get variable using self.request.get('id'). However I haven't been able to figure out how to update the form field. I examined the widget documentation <a href="http://packages.python.org/z3c.form/widget.html" rel="nofollow">http://packages.python.org/z3c.form/widget.html</a> but none of the suggestions have worked.</p> <pre><code>class IUpdateEmailFormSchema(interface.Interface): # -*- extra stuff goes here -*- """ """ memberID = schema.TextLine(title=(u'Member id')) email = schema.TextLine(title=(u'Email'), description=(u'The email')) class updateEmailForm(form.Form): fields = field.Fields(IUpdateEmailFormSchema) label = _(u'Change Email') ignoreContext = True @button.buttonAndHandler(u'Update') def handleUpdate(self,action): data, errors = self.extractData() if data.has_key('email'): portal_membership = getToolByName(self.context, 'portal_membership') member = portal_membership.getMemberById(data['memberID']) def updateWidgets(self): print "This is update widget \n\n" import pdb; pdb.set_trace() print self.request.form['id'] #Does not work as specified in http://packages.python.org/z3c.form/widget.html #self.widgets["memberID"].value = self.request.get('id').encode('utf-8') form.Form.updateWidgets(self) updateEmailFormView = wrap_form(updateEmailForm) </code></pre> <p>*Update: updateWidget wasn't correctly indented.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload