How to change the properties of a ZClass instance
Hi everyone, I am having a hard time changing the properties of an ZClass instance. This is what I have done so far: I created a producted called MTB_HQ. Within that product I created the ZClass "racedate". The ZClass has the a propertysheet called "date_properties". The sheet contains the properties "date_day","date_month","date_year","date_sort","title","discipline","location". All string type. 2nd I edited the "racedate_add" method as described in the "Searcheable Job Board"-How-To (unique timestamp ids, etc). Then I made a html form in: | |--mtb_hq | | admin The form calls the method "addracedate.dtml" in /mt_hq/admin/racedates. Here's the code: **************************** "addracedate.dtml" --------------------------- <dtml-call "REQUEST.set ('date_sort', year_html+month_html+day_html)"> <dtml-call "REQUEST.set ('title', location_html+' '+day_html+'.'+month_html+'.'+year_html)"> <dtml-call "REQUEST.set ('date_day', day_html)"> <dtml-call "REQUEST.set ('date_month', month_html)"> <dtml-call "REQUEST.set ('date_year', year_html)"> <dtml-call "REQUEST.set ('location', location_html)"> <dtml-call "REQUEST.set ('discipline', discipline_html)"> <dtml-with "manage_addProduct['MTB_HQ']"> <dtml-call "racedate_add(_.None, _, NoRedir=1)"> </dtml-with> <dtml-call "RESPONSE.redirect ('../index.htm')"> ****************************** Ok, so now I have the instance with the new properties and I can display it and everything - fine! But what do I do now when I want to change the properties of an existing ZClass instance through a web form? I tried back and forth wit manage_changeProperties but I jsut can't get it to work. Believe me I searched through all the How-Tos and documentation available but couldn't find any hint that got me further. My idea is to create a web form that is filled with the properties of existing ZClass. The you can make changes and the form calls a method that does the changing of the properties. But how do I do that? My web form (very basic now, not formatted in any way) right now looks like this: *************** "editracedates_form.htm" --------------------------------------- <dtml-with racedates> <dtml-in "Catalog(id=obj_id)"> <form method="post" action="racedates/changeRaceDate.dtml"> <p> Day <input type="text" name="day_html" value ="<dtml-var date_day>"> Month <input type="text" name="month_html" value ="<dtml-var date_month>"> Year <input type="text" name="year_html" value = "<dtml-var date_year>"> </p> <p> <input type="text" name="location_html" value ="<dtml-var location>"> location <input type="text" name="discipline_html" value ="discipline"> discipline </p> <p> <input type="submit" name="Button" value="Abschicken"> </p> </form> </dtml-in> </dtml-with> **************** How should the dtml-method "changeracedate.dtml" look like? Or could one of you guys point my nose at the right doc or how-to? I have really been playing around with this quite a while and just can't figure out how to use mange_changeProperties right! Many, many thanks in advance and sorry for this quite lenghty posting. Jan Lentfer
Jan Lentfer wrote:
Hi everyone,
I am having a hard time changing the properties of an ZClass instance.
This is what I have done so far:
I created a producted called MTB_HQ. Within that product I created the ZClass "racedate". The ZClass has the a propertysheet called "date_properties". The sheet contains the properties "date_day","date_month","date_year","date_sort","title","discipline","location". All string type.
[snip]
My idea is to create a web form that is filled with the properties of existing ZClass. The you can make changes and the form calls a method that does the changing of the properties. But how do I do that?
Create the form as an instance method of the ZClass (under the methods tab). Then just insert the property values like: <input type="text" name="location" value="&dtml-location;"> Make sure that the names of the form fields match exactly with your property names. [snip]
How should the dtml-method "changeracedate.dtml" look like? Or could one of you guys point my nose at the right doc or how-to? I have really been playing around with this quite a while and just can't figure out how to use mange_changeProperties right!
The action method (which should also be an instance method of the ZClass) should look something like this: <dtml-call expr="propertysheets.date_properties.manage_changeProperties(REQUEST)"> <dtml-call name="reindex_object"> <--- If it is CatalogAware <dtml-call expr="REPONSE.redirect('index_html')"> hth, -- | Casey Duncan | Kaivo, Inc. | cduncan@kaivo.com `------------------>
participants (2)
-
Casey Duncan -
Jan Lentfer