Custom receipt plugin label on a per form basis?

kokkentor

Member
As far as I can see, the receipt plugin label is fixed. Does anyone have any thoughts as to how to enable different labels for different forms?
Thanks! :)
 
Perhaps I use wrong plugin. What I want is for the user to be able to choose (by checkbox) wheter (a copy of) the form shall be sent to a specific email-address. Or even better: for the user also to choose from email addresses in a dropdown.
(Asking much, wanting more :-D )
 
You can add an element containing the email addresses (dbjoin, dropdown), then using the element placeholder in receipt's "send confirmation...".

Or use the email plugin where you can evaluate the "email to" (e.g. sending to multiple emails selected via a checkbox element or dbjoin as checkbox); you can use the condition field to determin if an email has to be sent at all (depending on one more radio or checkbox element).
 
Thanks!
I am using the email plugin via a checkbox element, of which I give the full element name in the form plugin options.

However, it won't send. It seems that the checkbox element's Sub options Label is used as email address instead of the Value...
 
Whenever I need to manage email addresses for form handling, I use a table to manage them, rather than a dropdown element. I've found that email addresses tend to change, as contacts come and go, requirements change, etc. If you are using (say) a dropdown element, you are restricted to managing that through the Fabrik element admin backend.

By using a table, you can manage the contact info through the front end or the backend, and control access using all the standard ACL controls in Fabrik. You can also hide the emails, as you don't have to include them in your form.

So say you have a table with 'id' (the PK), 'name' and 'email'. You would create a join element, using 'id' as the key and 'name' as the label.

Then in things like the email plugin, you do do something like this in your 'email to (eval)', assuming your contact element's full name is 'yourtable___contact':

PHP:
$db = JFactory::getDBO();
$my_email = '';
$contact = $formModel->_formData['yourtable___contact_raw'];
if (is_array($contact)) {
   $contact = $contact[0];
}
if (!empty($contact)) {
   $db->setQuery("SELECT email FROM contacts WHERE id = " . $db->Quote($contact));
   $my_email = $db->loadResult();
}
return $my_email;

End result is, you have a setup which requires no admin access to the backend to make changes to, you don't have to render the email addresses in the form data, and you never have to modify the PHP code in the email plugin.

And of course, if you ever move away from Fabrik as your platform, your email contact data is still in an industry standard format, easily migrated and re-used.

-- hugh
 
PS, if you need to select more than one recipient, you can use the same technique, setting your database join to "checkbox" mode, but the PHP in the 'email to (eval)" would be slightly different.

-- hugh
 
Hi and thanks cheesegrits!
I did as you suggusted, and the drop-down shows up all right, but I get the following errror message:

Could not send email to ..., invalid address

Any ideas?
 
Does it literally say "..." as the invalid address?

Can you paste the exact code you are using.

-- hugh
 
The "..." was a replacement for a name and an email address.

I don't get an error msg anymore. The emailaddress is recorded in the db table, but no email is sent.

Email to (eval) code:
Code:
$db = JFactory::getDBO();
$my_email = '';
$contact = $formModel->_formData['henvendelser___Send_Copy_To_raw'];
if (is_array($contact)) {   $contact = $contact[0];
}
if (!empty($contact)) {   $db->setQuery("SELECT epost FROM kontakter WHERE id = " . $db->Quote($contact));   
$my_email = $db->loadResult();
}
return $my_email;
 
You can examine what you get with

Code:
if (!empty($contact)) {   
$q="SELECT epost FROM kontakter WHERE id = " . $db->Quote($contact); 
var_dump($q);
$db->setQuery($q);    
$my_email = $db->loadResult();
var_dump($my_email);exit;
...
 
She is saying to use var_dump() to output what those variables are being set to in your code, to help work out what is going on. So just modify your code as per her suggestion. Then when you submit the form, you should see some debug output in an otherwise empty window. Paste the output here.

BTW, you said "name and email" was being output by J! as invalid. That doesn't sound right. Are you putting just email (hugh.foo@bar.com) in the email field in your table, or the name/email format like "Hugh Foo <hugh.foo@bar.com>"?

-- hugh
 
Thanks, but using the following doesn't give any feedback on what happens.

Code:
$db = JFactory::getDBO();
$my_email = '';
$contact = $formModel->_formData['henvendelser___Send_Copy_To_raw'];
if (is_array($contact)) {   $contact = $contact[0];
}
if (!empty($contact)) {   
$q="SELECT epost FROM kontakter WHERE id = " . $db->Quote($contact); 
var_dump($q);
$db->setQuery($q);    
$my_email = $db->loadResult();
var_dump($my_email);exit;
return $my_email;

The code doesnt send email. Well
 
There's a closing } missing before the return.
Running this code should show you a blank page displaying the query + the email.
 
PS, if you need to select more than one recipient, you can use the same technique, setting your database join to "checkbox" mode, but the PHP in the 'email to (eval)" would be slightly different.

-- hugh
How different would the PHP be? Do you have an example?
Thanks!
 
If there's no blank page the code isn't running at all (because of an error) or $contact is empty.
So what you can test:
set Joomla error reporting to maximum
put a var_dump($contact);exit; before the if
move the other varDumps directly before the return (at the moment they are inside the if)

Is the mail sent if you omit the eval code and put a fix address in send to?
 
Have var_dump($contact) at different places.
$contact is always NULL

Mail is sent if eval code is omitted and fixed address is put in send to
 
It seems like the databasejoin element's options data has mixed up value with label.
Choosing the db table's email column as the element's Label solves my problem of getting a "invalid email address" feedback.
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top