[Zope] Formulator advice requested

Jean Jordaan jean@upfrontsystems.co.za
Thu, 20 Sep 2001 14:08:03 +0200


Hi all

I'd like to start using Formulator for forms as much as possible.
Now I'm looking for info about programmatic use of Formulator.

Is it possible to get Forms out to the filesystem in any way? Or 
at least to get the code for the creation of the Form onto the 
filesystem? By Form creation code I mean: enumerate fields, types, 
names, validators, preferably in a block of Python. Then call an 
Add method if the Form doesn't exist yet, or manage_changeProperties 
if it does. Has anyone been doing this, and would you be willing to 
share code? I've googled the mailing lists but only came up with 
release announcements. 

This is a rough cut that works from DTML. The first time you run 
it, uncomment the block that does the creating::

    <dtml-var standard_html_header>
    <h2><dtml-var title_or_id> <dtml-var document_title></h2>

    <h3> Adding a form
    </h3>

    <dtml-comment> 
    <dtml-if newForm>
        <dtml-call "manage_delObjects('newForm')">
    </dtml-if>

    <dtml-call "REQUEST.set('submit', 'add')">
    <dtml-comment> 

    This returns to the management interface without executing the rest
    of the script. :/

    </dtml-comment>
    <dtml-with "manage_addProduct['Formulator']">
        <dtml-call "manage_add('newForm', 'title', REQUEST)">
    </dtml-with>
    </dtml-comment>

    <dtml-with newForm>
    <dtml-call "manage_addField('stringF', 'string field', 'StringField')">
    <dtml-call "manage_addField('textF', 'textarea', 'TextAreaField')">
    <dtml-comment>

    This leaves the management interface. :/

    </dtml-comment>
    </dtml-with> 

    <dtml-var standard_html_footer>

-- 
jean