Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>First creating form without grok is not that hard and do not depends on your Operating System.</p> <p>Creating a form is always the same. Here is how I proceed:</p> <ul> <li>Some imports</li> </ul> <pre class="lang-py prettyprint-override"><code>from Products.Five.browser import BrowserView from plone.autoform.form import AutoExtensibleForm from plone.app.z3cform import layout from zope import interface from zope import schema from zope import component from z3c.form import form from collective.my.i18n import _ </code></pre> <ul> <li>Create a schema</li> </ul> <pre class="lang-py prettyprint-override"><code>class AddFormSchema(interface.Interface): what = schema.Choice( title=_(u"What"), vocabulary="plone.app.vocabularies.UserFriendlyTypes" ) where = schema.Choice( title=u"Where", vocabulary="collective.my.vocabulary.groups" ) </code></pre> <ul> <li>create a generic adapter to fill the form from anywhere</li> </ul> <pre class="lang-py prettyprint-override"><code>class AddFormAdapter(object): interface.implements(AddFormSchema) component.adapts(interface.Interface) def __init__(self, context): self.what = None self.where = None </code></pre> <ul> <li>Then write the form</li> </ul> <pre class="lang-py prettyprint-override"><code>class AddForm(AutoExtensibleForm, form.Form): schema = AddFormSchema form_name = 'add_content' </code></pre> <ul> <li>Add a view</li> </ul> <pre class="lang-py prettyprint-override"><code>class AddButton(layout.FormWrapper): """Add button""" form = AddForm </code></pre> <ul> <li>Now ZCML time this is the step you don't need when using grok:</li> </ul> <pre class="lang-xml prettyprint-override"><code>&lt;adapter factory=".my.AddFormAdapter"/&gt; &lt;browser:page for="*" name="my.addbutton" class=".my.AddButton" template="addbutton.pt" permission="zope2.View" /&gt; </code></pre> <p>Should you move from grok:</p> <p>This is depending of what are you doing. For an addon I say Yes but for a project, it's up to you.</p> <p>Grok is not parts of the already big Zope. So adding dependency is something that always should be done only if needed. Grok is an option so I have never used it.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload