Magento2 background Development Grid curd content deletion and change check

Source: Internet
Author: User
Tags magento2

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 ');
}
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.