Return ListboxField Values in Email

Silverstripe Version:



I am trying to update my public contact form to include a ListboxField. I got the field to display correctly on the page; however, in the email that is sent the selected values do not return.


class ContactForm extends Form {

    public function __construct($controller, $name) {

		$fields = FieldList::create(
 // there are other fields in this
			ListboxField::create('MoreInformation', 'I would like more information about:', array(
				'Joining as a Consultant'=>'Joining as a Consultant',
				'Hosting a Gathering'=>'Hosting a Gathering',
				'Purchasing a Product'=>'Purchasing a Product',
				'Receiving Your Monthly Inspiration Living Newsletter'=>'Receiving Your Monthly Inspiration Living Newsletter'

		$actions = FieldList::create(
			FormAction::create('process','Submit')->addExtraClass('button small orange right')

        parent::__construct($controller, $name, $fields, $actions);


	public function process($data, $form) {
		$contactPage = ContactPage::get()->First();
		$submission = new ContactMessage($data);
		$From = $data['Email'];
		$To = (!empty($contactPage->FormEmail) ? $contactPage->FormEmail : '');
		$Subject = "Website Contact Form";  	  
		$email = new Email($From, $To, $Subject);



class ContactMessage extends DataObject {
	private static $db = array(
		'FirstName' => 'Varchar(255)',
		'LastName' => 'Varchar(255)',
		'Address' => 'Text',
		'City' => 'Varchar(255)',
		'State' => 'Varchar(255)',
		'PostalCode' => 'Varchar(255)',
		'Email' => 'Varchar(255)',
		'Phone' => 'Varchar(255)',
		'Source' => 'Varchar(255)',
		'Message' => 'Text',
		'MoreInformation' => 'Varchar(255)',
	private static $default_sort = 'Created DESC';

	static $summary_fields = array(
		'Created' => 'Created',
		'FirstName' => 'FirstName',
		'LastName' => 'LastName',
		'Email'   => 'Email',


    <td>More Information: $MoreInformation</td>

I would guess that MoreInformation would be an array, so in your process() method you might need to do something like:

$submission->MoreInformation = implode(', ', $data['MoreInformation']);

Thank you for your response. I did try that, but it didn’t seem to make any difference.

We have decided to go a different direction to get this form to work like we need it to.