[SOLVED] Email not send with multiple select in Cascading DropDown

Status
Not open for further replies.

keianrad

Member
I load emails form contact list by a cascading dropdown element, result renders as multi select.

There is not problem when I choose only one email address but when I choose more than one email address, email doesn't send and it shows "invalid address"!!!

And also how can I send email to the all email address that load by cascading without selecting?
 
I'll have a look at the first issue here and get back to you.

The second issue, do you mean if you don't select anything you want it to go to all the options fro the cdd, but without selecting any? Just automatically send to all? Would you want to override that behaviour if any were selected?

-- hugh
 
Yeah, as I thought, the issue with multiple selections is that the data has already been formatted for display, and when there are multiple selection, that means it is in the form ...

Code:
<ul class="fabrikRepeatData">
   <li>test1@example.com</li>
   <li>test2@example.com</li>
</ul>

And the "non formatted" data is the raw FK values (3, 5, 6, etc).

So you'll have to use an "Email to (eval)" to derive the addresses you want, either from the value of the "watched" element (if you just want all matching emails, as per your second question), or from the raw FK values of the email element (if you want the selected ones).

So say your "watched" element is "mytable___company", which is a simple join rendered as a dropdown, and your email CDD element is "mytable___contacts" ... which is joined to a "contacts" table which has a PK field "id" (which you have selected as the value of the CDD join setup), a "company_id" FK to the company table (your "watched" FK in the CDD setup), and an "email" field ... you can either do this:

1) Load all emails from 'contacts' for the selected 'company', regardless of CDD selection:

Code:
$companyId = $this->data['mytable___company_raw'];
$companyId = is_array($companyId) ? $companyId[0] : $companyId;
if (!empty($companyId) {
   $myDb = JFactory::GetDbo();
   $myQuery = $myDb->getQuery(true);
   $myQuery->select('email')->from('contacts')->where('company_id = ' . $myDb->quote($companyId));
   $myDb->setQuery($myQuery);
   $myEmails = $myDb->loadColumn();
   return implode(',', $myEmails);
}
return '';

2) Load just those selected in the CDD:

Code:
$contactIds = $this->data['mytable___contacts_raw'];
if (!empty($contactIds) {
   $myDb = JFactory::GetDbo();
   $myQuery = $myDb->getQuery(true);
   $myQuery->select('email')->from('contacts')->where('id IN (' . implode(',', $contactIds) . ')');
   $myDb->setQuery($myQuery);
   $myEmails = $myDb->loadColumn();
   return implode(',', $myEmails);
}
return '';

-- hugh
 
Thank you hugh, I really get confused. It doesn't show any email.

I think I didn't explain well. There are two lists named "Contacts" and "Clients". the contact has join to the clients by a database join element named "Client Id". In the contacts list there are some contact and sub contact that are related to gether by the "client id".
I need to load all emails from contact list which are related to the client. in other words all contact with the same "client id"

Element Setting:
CCD Element: "{app_emails___emails}" in the "email" form.
List: "contacts"
id: "id",
Label: "Email"
Watch Element: "client id"
foreign key: "client id"

Eval options:
$clientId = $this->data['app_emails___client_raw'];
$clientId = is_array($clientId) ? $clientId[0] : $clientId;
if (!empty($clientId) {
$myDb = JFactory::GetDbo();
$myQuery = $myDb->getQuery(true);
$myQuery->select('email')->from('contacts')->where('client_id = ' . $myDb->quote($clientId));
$myDb->setQuery($myQuery);
$myEmails = $myDb->loadColumn();
return implode(',', $myEmails);
}
return '';

I have very basic knowledge of php. I don't know if I changed it correctly. but it doesn't return any thing.
 
Please send me your IP, might be your IP blocked by the server firewall.

And can you ping the site from your computer (not any ping website) and send a screen shot. then I will talk to the support for solve it.
This problem happened before also.
 
I reconnected through a VPN, which worked for about 2 minutes, then it locked me out again. So I changed VPN location to pick up a new IP, and so far I'm still able to use it.

Can you make my account a super admin? There's a weird error, I need to up the error reporting levels.

-- hugh
 
OK, it's throwing:

syntax error, unexpected '{'

... in ...

plugins/fabrik_element/cascadingdropdown/cascadingdropdown.php

... at line 365, which is in _getOptions(), called by getEmailValue().

That error shouldn't be there, there's nothing in the current code which would cause that. Have you modified that file at all, perhaps while searching for the issue with CDD email values?

-- hugh
 
It's actually throwing the same error in the AJAX call when the form loads, now, as that also calls _getOptions().

-- hugh
 
OK, I finally figured out the problem.

You had put that code I gave you in the "Eval options" setting in the CDD element, which is why that error was getting thrown by the CDD code.

It was supposed to go in the "Email to (eval)" of the email plugin settings, right there under the main "Email to" option, in the "To" tab:

So you'll have to use an "Email to (eval)" to derive the addresses you want

I know they both have the word "eval" in them, but the place you put it says nothing about "Email to". If you aren't sure about advice / instructions, it's best to ask for clarification.

Should be working now, with a couple of fixes to the code.

-- hugh
 
Thank youuuuuuuuuuuuuuuu.
Email is working. The only thing, when I open the email form, browser shows me an popup error: "Parsererror" and I should click on open to be able you the form.
 
I can't get at your site again. It lets me in for a few minutes if I use a VPN, but then that IP seems to get banned, and I have to switch to another VPN.

You'll have to get that sorted out before I can work on your site any more.

And FYI, just this one issue has already eaten up almost 2 hours of time, as it took me that long to figure out you'd put the code in the wrong place. There is a finite limit on the amount of time I can provide on a subscription support basis, especially when it comes to custom code. We're getting close to the point where I'm going to have to suggest that we do this on a per-hour basis.

But get your site access issue fixed, and I'll see if I can figure out that load error.

-- hugh
 
I can't get at your site again. It lets me in for a few minutes if I use a VPN, but then that IP seems to get banned, and I have to switch to another VPN.

You'll have to get that sorted out before I can work on your site any more.

And FYI, just this one issue has already eaten up almost 2 hours of time, as it took me that long to figure out you'd put the code in the wrong place. There is a finite limit on the amount of time I can provide on a subscription support basis, especially when it comes to custom code. We're getting close to the point where I'm going to have to suggest that we do this on a per-hour basis.

But get your site access issue fixed, and I'll see if I can figure out that load error.

-- hugh
Send me your IP address please then I will check it with my host support.
 
Last edited:
It's not a single IP address. I've burned through about 20 so far. As I said, each time it blocks one, I have to switch my VPN to a different location, so the IP changes. That lasts a few minutes, then I get locked out again.

But my primary IP is 75.76.122.43, if they want to whitelist that.

-- hugh
 
OK, that's coming from the autofill, a combination of having "autofill on load" enabled, and the value being empty.

Fixed in this commit:

https://github.com/Fabrik/fabrik/commit/a205651776c40f653be4b426fe75f5b897d5446d

If you don't feel like updating from github, I've "fixed" it on your site by setting the error reporting level back to "default". I had set it up to maximum for testing the other issues. Putting it back to default stops the warning messaging getting thrown into the response to the autofill, so you won't see the "parse error" any more. And it's just a warning, not an error, doesn't affect how the plugin functions.

-- hugh
 
Status
Not open for further replies.
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top