Feature No Code Attached Yet
avatar BrainforgeUK
BrainforgeUK
17 Oct 2021

Steps to reproduce the issue

Code in commponent

if ($disabled != $name)
{
	// Normal link button behaviour
	$toolBar->linkButton($icon)
		->text('COM_MYSTUFF_' . strtoupper($name))
		->url(Route::_('index.php?option=com_mystuff&view=' . $name));
}
else
{
	// We want to show as a standard disabled button
	$toolBar->standardButton($icon)
		->text('COM_MYSTUFF_' . strtoupper($name))
		->attributes(array('disabled'=>'disabled'));
}

// Emulates 'ToolbarHelper::cancel' we want to avoid form post
$toolBar->linkButton('cancel', Text::_('JCANCEL'))
	->url(Route::_('index.php?option=com_mystuff'))
	->buttonClass('button-cancel btn btn-danger');

Expected result

Toolbar buttons function as expected but it would be better if the component code could be simplified, and easier to read / understand, by allowing this:

$toolBar->linkButton($icon)
	->text('COM_MYSTUFF_' . strtoupper($name))
	->url(Route::_('index.php?option=com_mystuff&view=' . $name))
	->disabled($disabled == $name);

$toolBar->cancel('cancel', Text::_('JCANCEL'))
	->url(Route::_('index.php?option=com_mystuff'))
	->disabled($disableCancel);    // Added for completeness

Save and other similarly implemented buttons could also be used in the same way.

Actual result

System information (as much as possible)

Additional comments

Provide more examples in the documention.
https://docs.joomla.org/Creating_a_toolbar_for_your_component
https://issues.joomla.org/tracker/joomla-cms/add

avatar BrainforgeUK BrainforgeUK - open - 17 Oct 2021
avatar BrainforgeUK BrainforgeUK - change - 17 Oct 2021
Labels Removed: ?
avatar joomla-cms-bot joomla-cms-bot - change - 17 Oct 2021
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 17 Oct 2021
avatar drmenzelit
drmenzelit - comment - 22 Oct 2021

Could you create a PR with test instructions for this?

avatar Hackwar Hackwar - change - 22 Feb 2023
Labels Added: ?
avatar Hackwar Hackwar - labeled - 22 Feb 2023
avatar HLeithner HLeithner - change - 21 Feb 2026
Status New Closed
Closed_Date 0000-00-00 00:00:00 2026-02-21 20:05:19
Closed_By HLeithner
Labels Added: Feature
Removed: ?
avatar HLeithner HLeithner - close - 21 Feb 2026

Add a Comment

Login with GitHub to post a comment