hasData(self::PARAM_BLOCK_GROUP)) { $this->_blockGroup = $this->_getData(self::PARAM_BLOCK_GROUP); } if ($this->hasData(self::PARAM_MODE)) { $this->_mode = $this->_getData(self::PARAM_MODE); } $this->addButton( 'back', [ 'label' => __('Back'), 'onclick' => 'setLocation(\'' . $this->getBackUrl() . '\')', 'class' => 'back' ], -1 ); $this->addButton( 'reset', ['label' => __('Reset'), 'onclick' => 'setLocation(window.location.href)', 'class' => 'reset'], -1 ); $objId = (int)$this->getRequest()->getParam($this->_objectId); if (!empty($objId)) { $this->addButton( 'delete', [ 'label' => __('Delete'), 'class' => 'delete', 'onclick' => 'deleteConfirm(\'' . __( 'Are you sure you want to do this?' ) . '\', \'' . $this->getDeleteUrl() . '\', {data: {}})' ] ); } $this->addButton( 'save', [ 'label' => __('Save'), 'class' => 'save primary', 'data_attribute' => [ 'mage-init' => ['button' => ['event' => 'save', 'target' => '#edit_form']], ] ], 1 ); } /** * Create form block * * @return $this */ protected function _prepareLayout() { if ($this->_blockGroup && $this->_controller && $this->_mode && !$this->_layout->getChildName( $this->_nameInLayout, 'form' ) ) { $this->addChild('form', $this->_buildFormClassName()); } return parent::_prepareLayout(); } /** * Build child form class name * * @return string */ protected function _buildFormClassName() { return $this->nameBuilder->buildClassName( [$this->_blockGroup, 'Block', $this->_controller, $this->_mode, 'Form'] ); } /** * Get URL for back (reset) button * * @return string */ public function getBackUrl() { return $this->getUrl('*/*/'); } /** * Get URL for delete button. * * @return string */ public function getDeleteUrl() { return $this->getUrl('*/*/delete', [$this->_objectId => (int)$this->getRequest()->getParam($this->_objectId)]); } /** * Get form save URL * * @see getFormActionUrl() * @return string */ public function getSaveUrl() { return $this->getFormActionUrl(); } /** * Get form action URL * * @return string */ public function getFormActionUrl() { if ($this->hasFormActionUrl()) { return $this->getData('form_action_url'); } return $this->getUrl('*/*/save'); } /** * Get form HTML. * * @return string */ public function getFormHtml() { $this->getChildBlock('form')->setData('action', $this->getSaveUrl()); return $this->getChildHtml('form'); } /** * Get form init scripts. * * @return string */ public function getFormInitScripts() { if (!empty($this->_formInitScripts) && is_array($this->_formInitScripts)) { return ''; } return ''; } /** * Get form scripts. * * @return string */ public function getFormScripts() { if (!empty($this->_formScripts) && is_array($this->_formScripts)) { return ''; } return ''; } /** * Get header width. * * @return string */ public function getHeaderWidth() { return ''; } /** * Get header css class. * * @return string */ public function getHeaderCssClass() { return 'icon-head head-' . strtr($this->_controller, '_', '-'); } /** * Get header HTML. * * @return string */ public function getHeaderHtml() { return '