Question

I am developing a site in plone and am currently writing a form using python and z3c.forms

Currently I am using an interface to define form fields like...

class IMyInterface(Interface):

    name = schema.TextLine(
            title=_(u"Name"),
            default=_(u"Name")
        )

and then assigning to fields like...

fields = field.Fields(IMyInterface)

this is then rendered in a template using tal like...

<div tal:replace="structure python: view.contents" />

I would like to render an onfocus attribute within the markup of the input. Is there a way to do this?

Was it helpful?

Solution

You can give arbitrary HTML attribute parameters to z3c.form widgets in updateWidgets() phase of your form.

http://collective-docs.readthedocs.org/en/latest/forms/z3c.form.html#modifying-a-widget

HTML attributes for widgets:

http://svn.zope.org/z3c.form/trunk/src/z3c/form/browser/widget.py?rev=103729&view=auto

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top