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.
We've moved the forum!
Please use forum.silverstripe.org for any new questions
(announcement).
The forum archive will stick around, but will be read only.
You can also use our Slack channel
or StackOverflow to ask for help.
Check out our community overview for more options to contribute.
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);
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.