I am trying to create an Event content type using Plone Form Gen. I have been using this tutorial in order to do this.
When creating an Event content type using the Add New... menu, you are given two fields to fill in that are start and end dates for the event, I would like my form to pull the information from these fields and apply it to the event content type I am using to create it.
My problem as I understand it is described with examples below:
The custom script adapter script contains the following:
obj.setDescription(form['replyto'])
I can see that it gets the contents for the Description of the Event content type from the following:
<input id="replyto" class="" type="text" size="30" name="replyto" />
The date/Time field when added to a PFG form, is made up of multiple <select>
inputs and not just one like the above, I guess this means there isn't a simple obj.setEndDate()
command for this... Although with no way to reference the select boxes I'm kind of stuck.
Does anyone know if it is possible to create an Event content type and specify start and end dates on it, using Plone Form Gen?
Edit
Using this link I have gotten around the original issue but I have run into more problems
I have adapted my script (using the above link) to look like the following:
target = context.viewjobs
form = request.form
from DateTime import DateTime
uid = str(DateTime().millis())
loc = form['location-of-event']
target.invokeFactory("Event", id=uid, title=form['topic'], event_url=loc)
obj = target[uid]
obj.setFormat('text/plain')
obj.setText(form['comments'])
obj.setDescription(form['replyto'])
obj.reindexObject()
(I used event_url just to test as I wasn't having any luck with the event_start
option).
It creates the event alright, but when I go to view the event I get:
Module zope.tales.expressions, line 217, in __call__
Module Products.PageTemplates.Expressions, line 147, in _eval
Module zope.tales.expressions, line 124, in _eval
Module Products.PageTemplates.Expressions, line 74, in boboAwareZopeTraverse
Module OFS.Traversable, line 317, in restrictedTraverse
Module OFS.Traversable, line 285, in unrestrictedTraverse
__traceback_info__: ([], 'location')
AttributeError: location
I have not referenced location anywhere in my script, and when I do, I get the same error.
Any thoughts would be appreciated