[Grok-dev] Customized grok.AddForm
Tim Cook
timothywayne.cook at gmail.com
Thu Jul 30 08:46:31 EDT 2009
I have an add form (below). The generic one does schema validation as
expected. But when I assign a custom template, it does not do schema
validation. The setUpWidgets function doesn't work in either case.
I created the custom template by copying the source output from the
generic (Grok generated) form and then adding some CSS and additional
text and graphics. The only thing I changed in the <form> itself was
the action in order to point to the view template in my previous email
about update().
Of course original just calls itself:
<form action="http://localhost:8080/dsedemo/immunizationsform"
method="post" class="edit-form"
enctype="multipart/form-data">
I changed it to:
<form tal:attributes="action python:view.url('immcalc')"
method="post" class="edit-form"
enctype="multipart/form-data">
So my questions are:
1. Why no schema validation in the customized form?
2. Why does the setUpWidgets function not work in either case?
Thanks,
Tim
*********************************************************
class ImmunizationsForm(grok.AddForm):
grok.context(dsedemo)
form_fields = grok.AutoFields(ImmunizationList)
#here we setup an alternate display form that has been customized
from the original generic add form.
#the URL though is still to /immunizationsform NOT to immadd.
template = grok.PageTemplateFile('dsedemo_templates/immadd.pt')
def setUpWidgets(self):
super(ImmunizationsForm, self).setUpWidgets()
self.widgets['hepatitisB'].width = 1
self.widgets['tetravalent'].width = 1
self.widgets['polio'].width = 1
self.widgets['rotavirus'].width = 1
@grok.action('Process')
def add(self, **data):
immlist = ImmunizationList()
self.applyData(immlist, **data)
self.context[name] = immlist
return self.redirect(self.url(self.context[name]))
*******************************************************************
--
Timothy Cook, MSc
Health Informatics Research & Development Services
LinkedIn Profile:http://www.linkedin.com/in/timothywaynecook
Skype ID == timothy.cook
***************************************************************
*You may get my Public GPG key from popular keyservers or *
*from this link http://timothywayne.cook.googlepages.com/home *
***************************************************************
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part
Url : http://mail.zope.org/pipermail/grok-dev/attachments/20090730/27804c38/attachment.bin
More information about the Grok-dev
mailing list