I'm trying to avoid writing out a few hundred fields in my custom addform for a plone dexterity object.
i've created a loop that is called from my customVisitFormTemplate.pt
def otherFields2(self):
#print "this gets called3"
customs=""
fields = field.Fields(ISiteVisit)
#print dir(fields)
for r in fields:
#print dir(r)
#print r.title()
if r.startswith("current") or r.startswith("landCover") or r.startswith("surrounding"):
pass
else:
print 'in others', r
customs=customs+"""<tal:field tal:replace='structure view/widgets/%s/@@ploneform-render-widget'/>""" % (r)
print customs
return customs
in the custom template i call it with this:
<fieldset>
<legend>General Info</legend>
<span tal:define="otherFields view/otherFields2">
<div tal:content="structure otherFields" />
</span>
</fieldset>
however, on execution the tal statement does not call the widget, and it outputs to html:
<tal:field tal:replace="view/widgets/siteID/@@ploneform-render-widget" />
if i use the following code directly in my custom temlpate:
<tal:field tal:replace="view/widgets/siteID/@@ploneform-render-widget" />
it outputs to html and it works:
<div id="formfield-form-widgets-siteVisitNotes" class="field z3cformInlineValidation kssattr-fieldname-form.widgets.siteVisitNotes">
<label class="horizontal" for="form-widgets-siteVisitNotes"> Site Visit Notes </label>
<div class="fieldErrorBox"></div>
<textarea id="form-widgets-siteVisitNotes" class="textarea-widget text-field" name="form.widgets.siteVisitNotes"></textarea>
</div>
how do i get my looped code from my .py file to output the same as the "direct" code?
thanks for any suggestions
after quite some playing around, i finally got this complexity working :).
here are still an issue in terms of having the title and input box stay together when resizing the page, but the sorting code works.