Magento2 background Development Grid curd content deletion and change check
Continue based on our Helloword plugin, based on established grid, crud on content
One: Add content Controller
app/code/magento/helloword/controller/adminhtml/manage/save.php
namespace Magento\helloword\controller\adminhtml\manage;
Class Newaction extends \magento\backend\app\action
{
Public Function Execute ()
{
$this->_forward (' edit ');
}
}
Two: Edit block display Form app/code/magento/helloword/block/adminhtml/bannerslider/edit.php
<?php
namespace Magento\helloword\block\adminhtml\bannerslider;
/**
* CMS block Edit form Container
*/
Class Edit extends \magento\backend\block\widget\form\container
{
protected function _construct ()
{
$this->_objectid = ' id ';
$this->_blockgroup = ' Magento_helloword ';
$this->_controller = ' Adminhtml_helloword;
Parent::_construct ();
$this->buttonlist->update (' Save ', ' label ', __ (' Save Image ');
$this->buttonlist->update (' delete ', ' label ', __ (' delete Image ');
$this->buttonlist->add (
' Saveandcontinue ',
Array
' Label ' => __ (' Save and Continue Edit '),
' Class ' => ' save ',
' Data_attribute ' => Array (
' Mage-init ' => Array (' button ' => Array (' event ' => ' Saveandcontinueedit ', ' target ' => ' #edit_form '))
)
),
-100
);
$this->_formscripts[] = "
function Toggleeditor () {
if (Tinymce.getinstancebyid (' block_content ') = null) {
Tinymce.execcommand (' Mceaddcontrol ', false, ' hello_content ');
} else {
Tinymce.execcommand (' Mceremovecontrol ', false, ' hello_content ');
}
}
";
}
/**
* Get Edit Form Container header text
*
* @return String
*/
Public Function Getheadertext ()
{
if ($this->_coreregistry->registry (' Helloword_helloword ')->getid ()) {
Return __ ("Edit Item '%1 '", $this->escapehtml ($this->_coreregistry->registry (' Helloword_helloword ')-> GetTitle ()));
} else {
Return __ (' New Item ');
}
}
}