Problem getting variable from URL into form email plugin

adriannunez

Member
Hello
I'm trying to send emails to addresses based on users id's, where the id is sent in the URL where the form is published (in front page).

This is my code:

Code:
$jinput = JFactory::getApplication()->input;
$foo1 = $jinput->get('var1');
$db =& JFactory::getDBO();
$query_email = "SELECT email FROM p4p7n_users WHERE id LIKE $foo1 LIMIT 0,1";
$db->setQuery($query_email);
$email = $db->loadResult();
return $email;

The URL is like this:
index.php?option=com_content&view=article&id=17&var1=357

where var1 is the Joomla's user ID

I did a test of that code in a calc element and it returns the correct email for every user id. The issue is that where this code is in an email form plugin the variable $foo1 is always NULL.

I tried it plublishing the form with {loadposition ...} and with a content plugin as Troester suggested me in the community forum: {fabrik view=form id=13 var1=[var1]}

It never returns an email address. But if I try {fabrik view=form id=13 table___element=[var1] var1=[var1]} the value of var1 is correctly displayed in the respective element.

Please, help me to get the email plugin working with this value from the URL.

Thanks in advance,
Adrian
 
Well, the email plugin runs on submission, not on form load. So code running on your form load will see var1 in the query string, but it won't be there when the form is submitted. Query string key=value pairs from the form's page load don't automagically get appended to form submissions.

However, if you are setting table___element to that value when you load the form, assuming it doesn't get changed and is submitted as-is with the form, then you should be able to get at table___element, either with $input->get(), or (if your code is in the "Email to (eval)", with a {table___element} placeholder, or (I think) $formModel->getElementData('table___element').

-- hugh
 
Thank you. I just tryed but there has to be something else, because Fabrik is not storing data in the database (also not sending email with the placeholder) . I tried with other forms and the same, not storing. I think it could be happening since the last time I updated from Github, about 4 days ago.
 
Hugh,
I solved the not-storing-data problem but the email address (that is correctly shown with the calc element in the form) is not being stored on the database when the form is submitted and the email is not being sended using placeholder nor $formModel.

Edit: with "Only Calc on Save" in the calc element the email address is also NULL in the database.
 
No, Hugh. I never tried to send mails in the calc element. I'm using the email form plugin ('Email to (eval)' or a placeholder in 'Email to'). But since it's not possible to have my code returning the email address in this plugin, I'm trying to store the email address in the database (with the calc element) and use its placeholder in the email form plugin. The problem is that the calc element shows the email, but it's not stored. When I see the database this value is always NULL.
 
Look, if I replace the code in the calc element (the one that returns the email address from de database) with
Code:
$email = "example@domain.com";
return $email;
Then example@domain.com is stored in the database, but the email plugin is still not sending the email to this address when using the {table___element} placeholder nor the other methods suggested.
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top