Silverstripe Version: 4.6
How do I get this associative array in my template and loop over the keys and values?
$postData = array('name' => 'Foo', 'Message' => 'This is my message');
$email = SilverStripe\Control\Email\Email::create()
->setHTMLTemplate('Email\\MyCustomEmail')
->setData([
'UserInput' => $postData
])
->setFrom($from)
->setTo($to)
->setSubject($subject);
if ($email->send()) {
//email sent successfully
} else {
// there may have been 1 or more failures
}
Now in my email template I’d like to loop over all user input which is in $postData
<% loop $input %> $Me.Value <% end_loop %>
But this just doesn’t work. Looking for a fix