[Zope3-Users] Re: browser:page and zope.formlib to
replace browser:addform?
TAHARA Yusei
yusei at domen.cx
Sun Dec 18 10:13:32 EST 2005
Hello.
At Sun, 18 Dec 2005 18:40:52 +0530,
baiju m wrote:
> > Also how to use templates along with zope.formlib forms?
>
> Hmm.. any help pointer?
You can use zope.formlib.namedtemplate for form's template.
By default, zope.formlib.form.default_page_template and pageform.pt is
used in forms.
So you can replace it to your own namedtemplate, simply like this::
class CompaniesView(form.AddForm):
form_fields = form.Fields(ICompany)
template = namedtemplate.NamedTemplate('company')
def create(self, data):
company = Company()
company.name = data['name']
company.description = data['description']
return company
company_page_template = namedtemplate.NamedTemplateImplementation(
ViewPageTemplateFile('companyform.pt'),
form.interfaces.IPageForm)
and configuration::
<adapter factory=".company_page_template" name="company" />
template::
<html>
<body>
<form action="." tal:attributes="action request/URL">
<div tal:repeat="widget view/widgets"
tal:content="structure widget">
</div>
<input tal:repeat="action view/actions"
tal:replace="structure action/render"
/>
</form>
</body>
</html>
Best regards,
--
Tahara Yusei
yusei at domen.cx
More information about the Zope3-users
mailing list