@andhi Irawan you can achieve same thing in Magento 2 using below code.
create events.xml on path Namespace\ModuleName\etc\adminhtml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="adminhtml_block_html_before">
<observer name="namespace_moodulename_observer_hidefields" instance="Namespace\ModuleName\Observer\HideFields" />
</event>
</config>
Create Observer file (Hidefields.php) on path Namespace\ModuleName\Observer
you can change the file name as per your choice.
<?php
namespace Namespace\ModuleName\Observer;
class HideFields implements \Magento\Framework\Event\ObserverInterface
{
protected $_request;
public function __construct(
\Magento\Framework\App\Request\Http $request
){
$this->_request = $request;
}
public function execute(\Magento\Framework\Event\Observer $observer)
{
$acionName = $this->_request->getFullActionName();
$ruleId = $this->_request->getParam('entity_id');
// $actionName is your admin edit form action
if($acionName === 'pricerules_lrpricerules_edit')
{
$block = $observer->getEvent()->getBlock();
if (!isset($block))
return $this;
if ($block->getType() == 'Namespace\ModuleName\Block\Adminhtml\Lrpricerules\Edit\Tab\Main')
{
$form = $block->getForm();
$filedArray = array();
// base_fieldset is the fieldset id defined in your form
$fieldset = $form->getElement('base_fieldset');
if($ruleId)
{
// fields ids array to remove from form
$filedArray = array('field1','field2');
if(!empty($filedArray))
{
foreach($filedArray as $fieldId)
{
$fieldset->removeField($fieldId);
}
}
}
}
}
return $this;
}
}