Walter Hupfeld wrote:
I want to build an instance of ZClass like
<dtml-call "REQUEST.set('id',REQUEST.form['id_neu'])"> <dtml-with "manage_addProduct['Tauschboerse']"> <dtml-call "SkizzeClass_add(_.None,_, NoRedir=1)"> </dtml-with> <dtml-call "REQUEST.set('meine_skizze',_[REQUEST.form['id_neu']])">
<dtml-call "_['meine_skizze'].propertysheets.Beschreibung.manage_changeProperties({ 'Name':REQUEST.form['Name'], 'Email':REQUEST.form['Email'], 'Sprache':REQUEST.form['Sprache'], .....
where 'Sprache' is the name of a CHECKBOX. It works fine, if all checkboxes are checked. But if not all checkboxes are checked, I will get an keyerror.
What can I do?
-- ----------- -------------------- Walter Hupfeld --------------------------------
Browser only submit a name/value pair for a check checkbox, hence the KeyError, however, zope has a facility (called marshaling) for specifying a default value. Or you can use REQUEST.get to similiar effect, like so: <dtml-call "_['meine_skizze'].propertysheets.Beschreibung.manage_changeProperties({ 'Name':REQUEST.form['Name'], 'Email':REQUEST.form['Email'], 'Sprache':REQUEST.get('Sprache', ''), ... BTW: You do not need to explicitly use REQUEST.form to access form variables, (although you can if you *really* concerned about name collisions), REQUEST.foo or REQUEST['foo'] work just as well. You can accomplish something similar on the form side with: <input type="checkbox" name="Sprache" value="checked value"> <input type="hidden" name="Sprache:default" value="unchecked value"> hth, -- | Casey Duncan | Kaivo, Inc. | cduncan@kaivo.com `------------------>