Skip to content

Instantly share code, notes, and snippets.

@phproberto
Created June 5, 2015 10:12
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phproberto/93958513db6d8a08645f to your computer and use it in GitHub Desktop.
Save phproberto/93958513db6d8a08645f to your computer and use it in GitHub Desktop.
Joomla: Get available values for a fieldsattach multiple selector
<?php
$db = JFactory::getDbo();
// Get the available offices
$offices = array();
$officeFieldId = 5;
$query = $db->getQuery(true)
->select('field.extras')
->from('#__fieldsattach AS field')
->where('field.id = ' . (int) $officeFieldId);
$db->setQuery($query);
$officesData = $db->loadResult();
if ($officesData)
{
$officesData = explode(chr(13), $officesData);
foreach ($officesData as $officeData)
{
$officeData = explode('|', $officeData);
if (count($officeData) != 2)
{
continue;
}
$offices[] = (object) array(
'alias' => trim($officeData[1]),
'name' => trim($officeData[0])
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment