Reputation: 4777
I'm developing a plugin for Plone. I have to show two different forms in a single page: two complete disjoint forms that will submit to two different pages. I've followed this tutorial http://docs.plone.org/develop/addons/helloworld/extend/form.html but with my actual low knowledge on Plone development I cannot figure out how to do this.
Upvotes: 0
Views: 103
Reputation: 7819
If you are not a Zope expert and you really want to provide two different form in the same view (but let me say that suggestions in comments above are good: are your sure you really need this?) I don't suggest you to use z3c.form
.
You can stay simple and draw the HTML yourself.
1- Register a new view
See http://docs.plone.org/develop/plone/views/browserviews.html#creating-a-view-using-zcml
2- Use simple HTML in the template, and add there two forms:
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
xmlns:tal="http://xml.zope.org/namespaces/tal"
xmlns:metal="http://xml.zope.org/namespaces/metal"
metal:use-macro="context/main_template/macros/master">
<body>
<metal:content-core fill-slot="content-core">
<metal:content-core define-macro="content-core">
<form action="@@endpoint1" method="post">
<!-- your HTML here -->
</form>
<form action="@@endpoint2" method="post">
<!-- your HTML here -->
</form>
</metal:content-core>
</metal:content-core>
</body>
</html>
Knowing TAL will help you if you don't need a static HTML (that is a very uncommon case).
3- Add two additional views (endpoint1
and endpoint2
) where you (probably) don't need to provide any template, but simple some logic.
It's really simple, you will be able to starts quickly... but you must handle yourself validation and server-side redirect. Sadly z3c.form
could simplify for you a lot of this stuff.
Upvotes: 2