I am trying to create an event content type using the Plone form generator. I used this tutorial to do this.
When creating an event content type using the Add New ... menu, you are given two fields to fill in: start and end dates, I would like my form to extract information from these fields and apply it to the type of event content that I use for it creation.
My problem, as I understand it, is described below:
The custom script adapter script contains the following:
obj.setDescription(form['replyto'])
I see that it gets content to describe the type of event content from the following:
<input id="replyto" class="" type="text" size="30" name="replyto" />
When adding a PFG to the form, the date / time field consists of several <select> inputs, and not just one, as indicated above, I think this means that there is no simple obj.setEndDate() command for this. Although I canโt refer to the boxes of choice, Iโm kind of stuck.
Does anyone know if it is possible to create an event content type and specify a start and end date using Plone Form Gen?
Edit
Using this link I had a problem with the original, but I had problems
I adapted my script (using the link above) to look like this:
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 only for verification, as I had no luck with the event_start option).
It fires the event in order, but when I go to view the event I receive:
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 did not mention the location anywhere in my script, and when I do this, I get the same error.
Any thoughts would be appreciated.