Instructions for creating a new edit screen and save an objects properties
Creating a new Edit Form
Add form input fields
Add a boolean type:
...
<select class="tablevalues"
tal:attributes="name MyBooleanProperty:boolean">
<option tal:repeat="boolProp python:(True,False)" tal:content="boolProp"
tal:attributes="value boolProp; selected python:boolProp==here.getMyBooleanProperty()"/>
</select>
...
This block of code creates a select dropdown with two options: True and False. The select dropdown is prepopulated with the value returned by getMyBooleanProperty. The value of this form field will be stored in the attribute MyBooleanProperty.
Add a text box type:
...
<textarea class="tablevalues" rows='5' cols="33"
tal:attributes="name MyTextProperty:text"
tal:content="here/getMyTextProperty">
</textarea>
...
This block of code creates a text box.The text box is prepopulated with the string value returned by getMyTextBoxProperty. The value of this form field will be stored in the attribute MyTextBoxProperty.
Add a text type:
...
<input class="tablevalues" type="text" size="40"
tal:attributes="value here/getMyStringProperty; name MyStringProperty"/>
...
This block of code creates a text field. The text field is prepopulated with the string value returned by getMyStringProperty. The value of this form field will be stored in the attribute MyStringProperty.
Add a select dropdown type:
...
<select class="tablevalues"
tal:attributes="name MySelectProperty">
<option tal:repeat="propOption here/getMySelectPropertyOptions"
tal:content="propOption"
tal:attributes="value propOption; selected python:propOption==getMySelectProperty()" />
</select>
...
This block of code creates a select dropdown where the option value and displayed option string are the same. A list of option values are returned by getMySelectPropertyOptions. The select dropdown is prepopulated by the value in getMySelectProperty. The value of this form field will be stored in the attribute MySelectProperty.
...
<select class="tablevalues"
tal:attributes="name MySelectProperty:int">
<option tal:repeat="propOptionTuple here/getMySelectPropertyOptionTuples"
tal:content="python:propOptionTuple[0]"
tal:attributes="value propOptionTuple[1]; selected python:propOptionTuple[1]==getMySelectProperty()" />
</select>
...
This block of code creates a select dropdown where the option value is an integer and displayed option is a string. A list of tuples containing the option values and displayed option string are returned by getMySelectPropertyOptionTuples. The select dropdown is prepopulated by the value in getMySelectProperty. The value of this form field will be stored in the attribute MySelectProperty.
Add the form action
...
<form id='MyForm' method="post" tal:attributes="action here/absolute_url_path">
...
The form action should be set to a function (i.e. here/absolute_url_path) that returns the path to the object being edited.
...
<input class="tableheader" type="submit"
name="saveProperties:method" value=" Save " />
...
This submit button name will be in the format saveProperties:method. saveProperties is the method name that will be executed when the submit button is clicked.
Add the save method
...
def saveProperties(self, REQUEST=None):
"""Save all Properties found in the REQUEST.form object.
"""
for name, value in REQUEST.form.items():
if getattr(self, name, None) != value:
self.setProperty(name, value)
return self.callZenScreen(REQUEST)
...
Create a saveProperty method in the effective object.