title: Plone custom edit/add form using Dexterity/Grok
body: <p>I am trying to create a custom edit/add form for my form package that I built using Dexterity types. I am following the Schema-driven types tutorial on the Plone Developer Documentation in the <a href="https://developer.plone.org/reference_manuals/external/plone.app.dexterity/schema-driven-types.html#" rel="nofollow">Dexterity Developer Manual</a> section. So far I have successfully created a Dexterity package with two content types: FAQ and Question. My FAQ Dexterity content type is a container, and my Question Dexterity content type can only be added within my FAQ container.</p>
  
  <p><strong>FAQ Content Type</strong> - <em>FAQ.py</em></p>
  
  <pre><code>from product.faq import MessageFactory as _
  from five import grok
  from plone.dexterity.content import Container
  from plone.directives import dexterity, form
  from zope import schema
  from zope import interface
  
  from Acquisition import aq_inner
  from Products.CMFCore.utils import getToolByName
  from product.faq.question import IQuestion
  
  class IFAQ(form.Schema):
      """ Project FAQ Container """
  
  class FAQ(Container):
      grok.implements(IFAQ)
  
  class View(grok.View):
      """ FAQ View Class """
      grok.context(IFAQ)
      grok.require('zope2.View')
  
      def questions(self):
          """ Return a catalog search result of questions to show """        
          context = aq_inner(self.context)
          catalog = getToolByName(context, 'portal_catalog')
  
          return catalog(object_provides=IQuestion.__identifier__,
                         path='/'.join(context.getPhysicalPath()),
                         sort_on='sortable_title')
  </code></pre>
  
  <p><strong>Question Type</strong> - <em>Question.py</em></p>
  
  <pre><code>from product.faq import MessageFactory as _
  from five import grok
  from plone.dexterity.content import Container
  from plone.directives import dexterity, form
  from zope import schema
  from zope import interface
  
  class IQuestion(form.Schema):
      """ Project FAQ Question Type """
  
      title = schema.TextLine(
          title=_(u"Question"),
      )
  
      answer = schema.TextLine(
          title=_(u"Answer"),
      )
  
      # Used to group questions into sections
      section = schema.TextLine(
          title=_(u"Section"),
      )
  
  class Question(Container):
      grok.implements(IQuestion)
  
  class Edit(grok.Form):
      """ FAQ Question Edit Class """
      grok.context(IQuestion)
      grok.require('zope2.View')
  </code></pre>
  
  <p>I need to be able to customize the form markup for both the add and edit views. So far I have been able to create an Edit view with no functionally. How do I add the functionally back to my form? </p>
  
  <p><em>edit.py</em></p>
  
  <pre><code>&lt;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"
        xmlns:i18n="http://xml.zope.org/namespaces/i18n"
        lang="en"
        metal:use-macro="context/main_template/macros/master"
        i18n:domain="product.faq"&gt;
      &lt;body&gt;
          &lt;metal:main fill-slot="content-core"&gt;
              &lt;metal:content-core define-macro="content-core"&gt;
                  &lt;h2&gt;This is a Edit Form&lt;/h2&gt;
                  &lt;ul class="list-unstyled"&gt;
                      &lt;li&gt;&lt;strong&gt;Plone's Title is: &lt;/strong&gt;&lt;i tal:content="context/Title"&gt;&lt;/i&gt;&lt;/li&gt;
                      &lt;li&gt;&lt;strong&gt;Plone's Description is: &lt;/strong&gt;&lt;i tal:content="context/Description"&gt;&lt;/i&gt;&lt;/li&gt;
                  &lt;/ul&gt;
                  &lt;form class="form-horizontal clearfix" role="form"&gt;
                      &lt;div class="form-group"&gt;
                          &lt;label for="faqQuestion" class="col-lg-2 control-label"&gt;Question&lt;/label&gt;
                          &lt;div class="col-lg-10"&gt;
                              &lt;input tal:attributes="value context/title" type="textfield" class="form-control" id="faqQuestion" placeholder="Enter a question"&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
                      &lt;div class="form-group"&gt;
                          &lt;label for="faqAnswer" class="col-lg-2 control-label"&gt;Answer&lt;/label&gt;
                          &lt;div class="col-lg-10"&gt;
                              &lt;input tal:attributes="value context/answer" type="textfield" class="form-control" id="faqAnswer" placeholder="Enter a answer"&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
                      &lt;div class="form-group"&gt;
                          &lt;label for="faqSection" class="col-lg-2 control-label"&gt;Section&lt;/label&gt;
                          &lt;div class="col-lg-10"&gt;
                              &lt;input tal:attributes="value context/section" type="textfield" class="form-control" id="faqSection" placeholder="Enter a grouping"&gt;
                         &lt;/div&gt;
                     &lt;/div&gt;
                     &lt;div class="btn-group pull-right"&gt;
                         &lt;a href="#" class="btn btn-primary"&gt;Save&lt;/a&gt;
                         &lt;a href="#" class="btn btn-danger"&gt;Cancel&lt;/a&gt;
                     &lt;/div&gt;
                 &lt;/form&gt;
             &lt;/metal:content-core&gt;
         &lt;/metal:main&gt;
     &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>My other issue is that how do I create a custom add view? When I click add my url points to <code>http://localhost:8080/demo/faq/++add++product.faq.question</code>. Is the ++add++ denoting that it is a widget?</p>
  
  <p>Thanks in advance.</p>