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