magento2 fetchone|magento2 后台开发 Grid curd内容增删改查

更新时间:2019-11-04    来源:magento    手机版     字体:

【www.bbyears.com--magento】

magento2 后台开发 Grid curd内容增删改查

继续基于我们的helloword插件,根据建立的grid, 对内容crud

magento2-crud

一:添加内容 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");
}
}

二:edit block 显示form app/code/Magento/HelloWord/Block/Adminhtml/Bannerslider/Edit.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");
}
}
}

本文来源:http://www.bbyears.com/wangyezhizuo/77183.html