coreRegistry = $coreRegistry; parent::__construct($context, $data); } /** * Initialize Post edit block * * @return void */ protected function _construct() { $this->_blockGroup = 'Mageplaza_Blog'; $this->_controller = 'adminhtml_comment'; parent::_construct(); $this->buttonList->add( 'save-and-continue', [ 'label' => __('Save and Continue Edit'), 'class' => 'save', 'data_attribute' => [ 'mage-init' => [ 'button' => [ 'event' => 'saveAndContinueEdit', 'target' => '#edit_form' ] ] ] ], -100 ); $this->buttonList->update('save', 'label', 'Save Comment'); $this->buttonList->remove('reset'); } /** * Retrieve text for header element depending on loaded Post * * @return string */ public function getHeaderText() { /** @var Comment $comment */ $comment = $this->coreRegistry->registry('mageplaza_blog_comment'); if ($comment->getId()) { return __("Edit Comment"); } return __('New Comment'); } /** * Get form action URL * * @return string */ public function getFormActionUrl() { /** @var Post $post */ $comment = $this->coreRegistry->registry('mageplaza_blog_comment'); if ($id = $comment->getId()) { return $this->getUrl('*/*/save', ['id' => $id]); } return parent::getFormActionUrl(); } }