10377 Posts in 2193 Topics by 1709 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1103 Views |
-
Allowing a user to add a calendar event

25 July 2009 at 5:50am
Is it possible to place the admin form on the front-end of the site to allow user submitted calendar events? It would need to have all of the functionality for adding a repeating event and so on except that a user-submitted event would need to be approved before it becomes live. I hope that's possible, because the calendar is perfect for what we'll be needing. Thanks.
-
Re: Allowing a user to add a calendar event

25 July 2009 at 8:29am
Of course. You should read the tutorial on creating custom forms. All you have to do is create a form with the same field names of the object you want to update and use $form->saveInto($dataobject);
-
Re: Allowing a user to add a calendar event

28 May 2011 at 8:24am Last edited: 1 June 2011 5:05am
Hi all - I've done the tutorials, and gone through both books trying to implement this, but there's something I'm clearly not getting (I'm a rank amateur at all of this - designer trying to turn dev, completely in love with SilverStripe).
Anyway: I've got this code in a subclass of Calendar.php:
public function AddEventForm() {
$form = new Form (
$this,
"AddEventForm",
new FieldSet (
new TextField('Title', _t('CalendarDateTime.TITLE', 'Title')),
new DatePickerField('StartDate', _t('CalendarDateTime.STARTDATE', 'Start Date')),
new TimeField('StartTime', _t('CalendarDateTime.STARTTIME', 'Start Time')),
new DatePickerField('EndDate', _t('CalendarDateTime.ENDDATE', 'End Date')),
new TimeField('EndTime', _t('CalendarDateTime.ENDTIME', 'End Time')),
new HtmlEditorField('Content', _t('CalendarDateTime.CONTENT', 'Content')),
new CheckboxField('is_all_day', _t('CalendarDateTime.IS_ALL_DAY', 'Is All Day?'))),
new FieldSet (
new FormAction('doSubmit','Add event')
));return $form;
}public function doSubmit($data, $form) {
$calendardatetime = new CalendarDateTime();
$form->saveInto($calendardatetime);
$calendardatetime->write();
Director::redirectBack();
}and it works, in that it successfully saves to the CalendarDateTime table, but doesn't get an EventID, and so doesn't show up in the calendar. I know I need to save fields to other tables, but which fields and which tables?
For this purpose, I don't need all the fancy date-pattern stuff so I was leaving it out of the front-end form, but maybe I need to include it somehow?Thanks in advance for any help, and for making SilverStripe such a joy to use*.
*Edit: I realized just now this may have come off snarkily, but I really meant it sincerely.
| 1103 Views | ||
|
Page:
1
|
Go to Top |

