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

placeholder #84

Closed
PythonLinks opened this issue Apr 22, 2019 · 3 comments
Closed

placeholder #84

PythonLinks opened this issue Apr 22, 2019 · 3 comments

Comments

@PythonLinks
Copy link

It would be wonderful if I could add a placeholder to a zope.schema field.
Or any other htmattribute for that matter.

@d-maurer
Copy link

It would be wonderful if I could add a placeholder to a zope.schema field.
Or any other htmattribute for that matter.

Can you provide an example what you mean by placeholder?

You could look at the tag module of dm.zope.schema and the related example in the example section. It uses the "tagged values" concept of zope.interface to add additional information to zope.schema fields. I use it in dm.zope.reseller to enhance schemas with information relevant for the management of corresponding data records in a relational database.

@jamadden
Copy link
Member

jamadden commented Apr 22, 2019

It's also possible (though probably not recommended --- I would stick with tags) to add new attributes to stock fields; these values are copied into bound instances (binding copies the __dict__ values to the bound object):

>>> from zope.schema import *
>>> from zope.interafce import Interface
>>> from zope.interface import Interface
>>> class IFoo(Interface):
...     field = Bytes(title='a bytes')
...     field.placeholder = 'my placeholder'
...
>>> IFoo['field'].placeholder
'my placeholder'
>>> IFoo['field'].bind(object()) is IFoo['field']
False
>>> IFoo['field'].bind(object()).placeholder
'my placeholder'

@jamadden
Copy link
Member

Closing since there've been no updates.

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

No branches or pull requests

3 participants