[Checkins] SVN: grokapps/SimpleViewletDemo/src/simpleviewletdemo/app Fixed validation errors, now the add form uses a template which does not include <html> and <body>

Tim Terlegård tim.terlegard at valentinewebsystems.se
Tue May 20 15:10:23 EDT 2008


Log message for revision 86858:
  Fixed validation errors, now the add form uses a template which does not include <html> and <body>
  

Changed:
  U   grokapps/SimpleViewletDemo/src/simpleviewletdemo/app.py
  A   grokapps/SimpleViewletDemo/src/simpleviewletdemo/app_templates/edit_form.pt
  U   grokapps/SimpleViewletDemo/src/simpleviewletdemo/app_templates/master.pt

-=-
Modified: grokapps/SimpleViewletDemo/src/simpleviewletdemo/app.py
===================================================================
--- grokapps/SimpleViewletDemo/src/simpleviewletdemo/app.py	2008-05-20 18:05:32 UTC (rev 86857)
+++ grokapps/SimpleViewletDemo/src/simpleviewletdemo/app.py	2008-05-20 19:10:22 UTC (rev 86858)
@@ -1,4 +1,5 @@
 import grok
+import os
 from zope.component import getMultiAdapter
 from zope.interface import Interface
 from zope.schema import TextLine
@@ -102,6 +103,7 @@
 
 class AddFruitForm(grok.AddForm):
     form_fields = grok.AutoFields(Fruit)
+    template = grok.PageTemplate(filename=os.path.join('app_templates', 'edit_form.pt'))
 
     @grok.action('Add fruit')
     def add(self, **data):

Added: grokapps/SimpleViewletDemo/src/simpleviewletdemo/app_templates/edit_form.pt
===================================================================
--- grokapps/SimpleViewletDemo/src/simpleviewletdemo/app_templates/edit_form.pt	                        (rev 0)
+++ grokapps/SimpleViewletDemo/src/simpleviewletdemo/app_templates/edit_form.pt	2008-05-20 19:10:22 UTC (rev 86858)
@@ -0,0 +1,61 @@
+<form action="." tal:attributes="action request/URL" method="post"
+      class="edit-form" enctype="multipart/form-data">
+
+  <h1 i18n:translate=""
+    tal:condition="view/label"
+    tal:content="view/label">Label</h1>
+
+  <div class="form-status"
+    tal:define="status view/status"
+    tal:condition="status">
+
+    <div i18n:translate="" tal:content="view/status">
+      Form status summary
+    </div>
+
+    <ul class="errors" tal:condition="view/errors">
+      <li tal:repeat="error view/error_views">
+         <span tal:replace="structure error">Error Type</span>
+      </li>
+    </ul>
+  </div>
+
+  <table class="form-fields">
+    <tbody>
+      <tal:block repeat="widget view/widgets">
+        <tr>
+          <td class="label" tal:define="hint widget/hint">
+            <label tal:condition="python:hint"
+                   tal:attributes="for widget/name">
+              <span class="required" tal:condition="widget/required"
+              >*</span><span i18n:translate=""
+                             tal:content="widget/label">label</span>
+            </label>
+            <label tal:condition="python:not hint"
+                   tal:attributes="for widget/name">
+              <span class="required" tal:condition="widget/required"
+              >*</span><span i18n:translate=""
+                             tal:content="widget/label">label</span>
+            </label>
+          </td>
+          <td class="field">
+            <div class="widget" tal:content="structure widget">
+              <input type="text" />
+            </div>
+            <div class="error" tal:condition="widget/error">
+              <span tal:replace="structure widget/error">error</span>
+            </div>
+          </td>
+        </tr>
+      </tal:block>
+    </tbody>
+  </table>
+
+  <div id="actionsView">
+    <span class="actionButtons" tal:condition="view/availableActions">
+      <input tal:repeat="action view/actions"
+             tal:replace="structure action/render"
+             />
+    </span>
+  </div>
+</form>

Modified: grokapps/SimpleViewletDemo/src/simpleviewletdemo/app_templates/master.pt
===================================================================
--- grokapps/SimpleViewletDemo/src/simpleviewletdemo/app_templates/master.pt	2008-05-20 18:05:32 UTC (rev 86857)
+++ grokapps/SimpleViewletDemo/src/simpleviewletdemo/app_templates/master.pt	2008-05-20 19:10:22 UTC (rev 86858)
@@ -1,5 +1,9 @@
-<html>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
+      lang="en">
 <head>
+    <meta tal:attributes="http-equiv string:Content-Type;
+                          content string:text/html;;charset=utf-8" />
     <tal:head content="structure provider:head" />
 </head>
 <body>



More information about the Checkins mailing list