public function getRepeatable()
{
$class = $this->class ? $this->class : $this->id;
$relationclass = $this->element['relationclass'] ? (string) $this->element['relationclass'] : '';
$value_field = $this->element['value_field'] ? (string) $this->element['value_field'] : 'title';
$translate = $this->element['translate'] ? (string) $this->element['translate'] : false;
$link_url = $this->element['url'] ? (string) $this->element['url'] : false;
if (!($link_url && $this->item instanceof DataModel)) {
$link_url = false;
}
if ($this->element['empty_replacement']) {
$empty_replacement = (string) $this->element['empty_replacement'];
}
$relationName = $this->form->getModel()->getContainer()->inflector->pluralize($this->name);
$relations = $this->item->getRelations()->getData($relationName);
$rels = array();
foreach ($relations as $relation) {
$html = '<span class="' . $relationclass . '">';
if ($link_url) {
$keyfield = $relation->getKeyName();
$this->_relationId = $relation->{$keyfield};
$url = $this->parseFieldTags($link_url);
$html .= '<a href="' . $url . '">';
}
if (!isset($this->valueField)) {
$this->valueField = $relation->getFieldAlias($value_field);
}
$value = $relation->{$this->valueField};
// Get the (optionally formatted) value
if (!empty($empty_replacement) && empty($value)) {
$value = JText::_($empty_replacement);
}
if ($translate == true) {
$html .= JText::_($value);
} else {
$html .= $value;
}
if ($link_url) {
$html .= '</a>';
}
$html .= '</span>';
$rels[] = $html;
}
$html = '<span class="' . $class . '">';
$html .= implode(', ', $rels);
$html .= '</span>';
return $html;
}