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');
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.
Provide more examples in the documention.
https://docs.joomla.org/Creating_a_toolbar_for_your_component
https://issues.joomla.org/tracker/joomla-cms/add
Labels |
Removed:
?
|
Labels |
Added:
No Code Attached Yet
|
Labels |
Added:
?
|
Could you create a PR with test instructions for this?