Here's my conundrum. My component has several elements and in the admin side lists of each element I have a standard "New" button to create a new record for that element. All my lists work bar 1 which happens to be the default list for the component. So if I have a blank list, ie no records showing in the list, I click the New button and nothing happens. If I change the filter to show a list with a status of say Archived (of which I have a couple of records), then the list is not empty as you would expect, and then when I click the new button, the form opens as expected for me to create a new record. Once I save that record, then remove the filter so it just displays published and unpublished records, then the new button works as it should.
Here is a snippet of my View Tmpl file in my addTemplate function.
$toolbar = Toolbar::getInstance('toolbar');
$canDo = ContentHelper::getActions('com_mycomponent','component',0);
ToolbarHelper::title(Text::_('COM_MYCOMPONENT_TITLE_POSITIONS'), 'positions.png');
$toolbar->link('JTOOLBAR_DASHBOARD', 'index.php?option=com_cpanel&view=cpanel&dashboard=mycomponent');
if ($canDo->get('core.create')) {
$toolbar->addNew('position.add');
}
if ($canDo->get('core.edit.state')) {
$dropdown = $toolbar->dropdownButton('status-group')
->text('JTOOLBAR_CHANGE_STATUS')
->toggleSplit(false)
->icon('fa fa-ellipsis-h')
->buttonClass('btn btn-info')
->listCheck(true);
$childBar = $dropdown->getChildToolbar();
$childBar->publish('positions.publish')->listCheck(true);
$childBar->unpublish('positions.unpublish')->listCheck(true);
$childBar->archive('positions.archive')->listCheck(true);
$childBar->checkin('positions.checkin')->listCheck(true);
if ($this->state->get('filter.state') != -2) {
$childBar->trash('positions.trash')->listCheck(true);
}
}
As always, any guidance appreciated.