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'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.

Archive /

Our old forums are still available as a read-only archive.

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

How to email data from CheckboxSetField in a Form


Go to End


1642 Views

Avatar
Martin Pales

Community Member, 19 Posts

21 November 2008 at 11:18am

Edited: 21/11/2008 11:19am

I have a CheckboxSetField in my form and would like to send those data in an email when the form is submitted. However, I am getting the following errors:

FATAL ERROR: ArrayData::__construct: Parameter needs to be an object or associative array
At line 39 in C:\Program Files\wamp\www\web\sapphire\core\ArrayData.php

and

FATAL ERROR: Object::__call() Method 'forTemplate' not found in class ''
At line 199 in C:\Program Files\wamp\www\web\sapphire\core\Object.php

user_error(Object::__call() Method 'forTemplate' not found in class '',256)
line 199 of Object.php

Object->__call(forTemplate,Array)

ArrayData->forTemplate()
line 420 of ViewableData.php

When I added forTemplate to the ArrayData.php, the second error was gone.

I use this code to populate template of the email:

$email->populateTemplate(array(
'FirstName' => $data['FirstName'],
'LastName' => $data['LastName'],
'Title' => $data['Title'],
'Company' => $data['Company'],
'Reason' => $data['Reason'],
'Email' => $data['Email'],
'Phone' => $data['Phone']
));

where Reason is an array data of the CheckboxSetField in my form.

Thanks.