Jump to:

11002 Posts in 2734 Topics by 1823 members

All other Modules

SilverStripe Forums » All other Modules » Allowing a user to add a calendar event

Discuss all other Modules here.

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

Page: 1
Go to End
Author Topic: 1311 Views
  • ptejera
    Community Member
    1 Post

    Allowing a user to add a calendar event Link to this post

    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.

  • UncleCheese
    4085 Posts

    Re: Allowing a user to add a calendar event Link to this post

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

  • mierla
    Community Member
    16 Posts

    Re: Allowing a user to add a calendar event Link to this post

    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.

Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.