21293 Posts in 5733 Topics by 2602 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 340 Views |
-
Set Email Address in Custom Form from SiteConfig

7 May 2012 at 11:19am
Instead of coding the email address into the doContactForm code, I'd like to be able to change it via the CMS in SiteConfig.
I understand how to do it if the form processor and database field are in the same Class…
public static $db = array(
'MailTo'=> 'Text'
);function doContactForm($data, $form) {
//Set data
$from = $data['Email'];
$to = $this->MailTo;
…
}So what's the best way to reference "MailTo" if that field was added to SiteConfig and the form processor was on Page.php?
Thanks
-
Re: Set Email Address in Custom Form from SiteConfig

7 May 2012 at 4:44pm Last edited: 7 May 2012 4:46pm
Hi Socks,
Call this from inside your function:
function doContactForm($data, $form) {
$config = SiteConfig::current_site_config();//Set data
$from = $data['Email'];
$to = $config->MailTo;
…
}This came from here:
http://doc.silverstripe.org/sapphire/en/reference/siteconfigI hope this helps.
Cheers
-
Re: Set Email Address in Custom Form from SiteConfig

8 May 2012 at 8:13pm
That's exactly what I needed. Thanks!
| 340 Views | ||
|
Page:
1
|
Go to Top |


