Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6083459
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:24:20+00:00 2026-05-23T11:24:20+00:00

I am trying to dynamically update a form field based on a variable that

  • 0

I am trying to dynamically update a form field based on a variable that is included in a HTTP get variable. Specifically http://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.

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 http://packages.python.org/z3c.form/widget.html but none of the suggestions have worked.

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)

*Update: updateWidget wasn’t correctly indented.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T11:24:21+00:00Added an answer on May 23, 2026 at 11:24 am

    updateWidgets method is the right place to do it.
    just you shouuld first call “form.Form.updateWidgets” and then do your
    changes (even better user super() as shown bellow):

    def updateWidgets(self):
        super(updateEmailForm, self).updateWidgets()
        id = self.request.get('id', None)
        if id:
            self.widgets["memberID"].value = id.encode('utf-8')
    

    so basically the error was the order

    and if there is no request (which is kinda weird and you are probably doing something worng there) then you can get it via:

    from zope.globalrequest import getRequest
    request = getRequest()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Question I am trying to dynamically get the default for a type that is
I'm trying to get a nested form view to update properly. This is however
I'm trying to dynamically update the HTML5 placeholder attribute of a text field using
I am trying to get a UIWebView to update dynamically, sort of like a
I am trying to figure out how I can update my sql query dynamically.
I'm trying to dynamically define functions that call through to another function that takes
My application needs to update tab indicator dynamically, I'm trying to do this by
I'm trying to update a Total: ( span.wrap p span ) field at the
I'm trying to dynamically update a table of values using SocketStream. I have a
I'm new to Flash/ActionScript 3, I'm trying to dynamically update the Object in a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.