3070 Posts in 869 Topics by 651 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 928 Views |
-
[SOLVED] Calling an email template function using a button

19 April 2011 at 4:24am Last edited: 19 April 2011 4:25am
Hi there,
I've been looking around the forum all day and so far i haven't been able to come up with a solution, i want to have a button on the screen that when clicked runs a function that is set to email instructions to an email group, i have most of it done but i don't seem to be able to make a button run the function. My code is below, as ever would welcome some pointers or even the answer :o)
function EmailSearchTeam() {
return new Form($this, '', new FieldSet(new HiddenField('Hidden')), new FieldSet(new FormAction('doEmailSearchTeam', 'Email the Team')));
}
function doEmailSearchTeam() {
$email = new Email();
$email->setTemplate('TestEmail');
$email->setFrom('xxxx@xxxxx.com');
$email->setTo('yyyyyy@yyyyyy.com');
$email->setSubject('New Event Added ');
$email->populateTemplate(Member::currentUser());
$email->populateTemplate(array(
'Title' => $this->owner->Title,
'Date' => $this->owner->StartDate,
'StartTime' => $this->owner->StartTime,
'Location' => $this->owner->Location,
'Contact1' => $this->owner->Contact1,
));
$email->send();
}Sorry should add, there are no errors it all looks like it works but no email is sent, i'm wondering whether you can actually call a function like this.
Hope someone can help.regards
Mick
-
Re: [SOLVED] Calling an email template function using a button

20 April 2011 at 1:28am
Well still trying to get this idea run, the email gets sent if i attach it to the onAfterWrite() function so i think the email code is fine, i just don't think the function is being called from the form button.
Is what i'm trying to do possible?
Mick
-
Re: [SOLVED] Calling an email template function using a button

20 April 2011 at 8:59pm
You're missing the 2 parameters in your doEmailSearchTeam function for the form handler to match. I think you need to change it too doEmailSearchTeam($data, $form)
-
Re: [SOLVED] Calling an email template function using a button

20 April 2011 at 9:35pm
Hi Willr,
Thanks for getting back, I've had those parameters in and out to no avail. It just doesn't seem to want call that function.
Mick
-
Re: [SOLVED] Calling an email template function using a button

21 April 2011 at 9:29am
Could you post that whole file? FYI the form and action need to be in a controller (not a dataobject) so that it can be posted to it after the form submits.
-
Re: [SOLVED] Calling an email template function using a button

21 April 2011 at 11:00pm
Hi ya,
I thought that was gonna be it, i was hoping that was gonna be it but alas it is on a controller, it's actually on UC's calendar.php file as i'm tweaking that so those two functions are added to the bottom of that.
I may have a work around i'm gonna try which will add functionality anyway which is to create a new table and write to that with a log of email sent then use the email function on the onAfterWrite() function to send it.
Cheers and Happy Easter.
Mick
-
Re: [SOLVED] Calling an email template function using a button

10 May 2011 at 8:50pm
Ok i have now got this part sussed, it was because of the static $allowed_actions = array which was on the page, i hadn't added my function to that list.
DOH!!!
ok now onto the next part which is to actually get the data.
regards
Mick
| 928 Views | ||
|
Page:
1
|
Go to Top |


