I created a form in backend like this:
I want to change save button text from 'Save' to 'Insert', here's my code:
Block\Adminhtml\Tools\Edit.php:
namespace Test\UploadFile\Block\Adminhtml\Tools;
use Magento\Backend\Block\Widget\Form\Container;
class Edit extends Container
{
protected $coreRegistry;
protected $toolsId=false;
public function __construct(
\Magento\Backend\Block\Widget\Context $context,
\Magento\Framework\Registry $registry,
array $data = []
) {
$this->coreRegistry = $registry;
parent::__construct($context, $data);
}
protected function _construct()
{
$this->_objectId = 'tools_id';
$this->_controller = 'adminhtml_tools';
$this->_blockGroup = 'Lime_UploadFile';
parent::_construct();
$toolsId = $this->getToolsId();
if (!$toolsId) {
$this->buttonList->remove('delete');
}
}
public function getHeaderText()
{
$toolsId = $this->getToolsId();
if (!$toolsId) {
return __('New File Item');
} else {
return __('Edit File Item');
}
}
public function getToolsId()
{
if (!$this->toolsId) {
$this->toolsId=$this->coreRegistry->registry('current_tools_id');
}
return $this->toolsId;
}
}
Best Answer
You just need to add
$this->buttonList->update()
to update existing buttons of admin form inEdit.php
As per your code you can change save button label like this:
By this same way, you can change other buttons like save and continue, reset, back and other admin buttons