Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

render input id correctly if it is changed #339

Closed
wants to merge 1 commit into from
Closed

render input id correctly if it is changed #339

wants to merge 1 commit into from

Conversation

jimgregory
Copy link
Contributor

It's sometimes necessary to change a form element's ID after it's been created (e.g., when there are multiple form elements with the same name). A bug existed that prevented the ID in the input widget from updating:

In [1]: from web import form

In [2]: f = form.Form(form.Textbox('x'))

In [3]: f.render()
Out[3]: u'<table>\n    <tr><th><label for="x">x</label></th><td><input type="text" id="x" name="x"/></td></tr>\n</table>'

In [4]: f.x.id = 'newx'

In [5]: f.render()
Out[5]: u'<table>\n    <tr><th><label for="newx">x</label></th><td><input type="text" id="x" name="x"/></td></tr>\n</table>'

Note the label's ID has been updated but not the input's ID. This fixes that bug.

It's sometimes necessary to change a form element's ID after it's been created (e.g., when there are multiple form elements with the same name).  A bug existed that prevented the ID in the input widget from updating:

    In [1]: from web import form

    In [2]: f = form.Form(form.Textbox('x'))

    In [3]: f.render()
    Out[3]: u'<table>\n    <tr><th><label for="x">x</label></th><td><input type="text" id="x" name="x"/></td></tr>\n</table>'

    In [4]: f.x.id = 'newx'

    In [5]: f.render()
    Out[5]: u'<table>\n    <tr><th><label for="newx">x</label></th><td><input type="text" id="x" name="x"/></td></tr>\n</table>'

Note the label's ID has been updated but not the input's ID.  This fixes that bug.
@jzellman
Copy link
Contributor

jzellman commented Feb 2, 2017

🚢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants