/**
* Get the rendering of this field type for a repeatable (grid) display,
* e.g. in a view listing many item (typically a "browse" task)
*
* @since 2.0
*
* @return string The field HTML
*
* @throws DataModelRequired
*/
public function getRepeatable()
{
if (!$this->item instanceof DataModel) {
throw new DataModelRequired(__CLASS__);
}
$config = $this->getConfig();
$html = '<div class="btn-group">';
// Render a published field
if ($this->item->hasField('enabled')) {
$publishedFieldName = $this->item->getFieldAlias('enabled');
if ($config['published'] || $config['unpublished']) {
// Generate a FieldInterfacePublished field
$publishedField = $this->getPublishedField($publishedFieldName);
// Render the publish button
$html .= $publishedField->getRepeatable();
}
if ($config['archived']) {
$archived = $this->item->getFieldValue($publishedFieldName) == 2 ? true : false;
// Create dropdown items
$action = $archived ? 'unarchive' : 'archive';
JHtml::_('actionsdropdown.' . $action, 'cb' . $this->rowid);
}
if ($config['trash']) {
$trashed = $this->item->getFieldValue($publishedFieldName) == -2 ? true : false;
$action = $trashed ? 'untrash' : 'trash';
JHtml::_('actionsdropdown.' . $action, 'cb' . $this->rowid);
}
// Render dropdown list
if ($config['archived'] || $config['trash']) {
$html .= JHtml::_('actionsdropdown.render', $this->item->title);
}
}
$html .= '</div>';
return $html;
}