Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

All other Modules /

Discuss all other Modules here.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Allowing a user to add a calendar event

Go to End

3 Posts   1658 Views


Community Member, 1 Post

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.


Forum Moderator, 4102 Posts

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);


Community Member, 16 Posts

28 May 2011 at 8:24am

Edited: 01/06/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 (
			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();

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.