![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/vendor/aheadworks/module-csblock/Block/Adminhtml/Csblock/ |
<?php namespace Aheadworks\Csblock\Block\Adminhtml\Csblock; /** * Class Edit * @package Aheadworks\Csblock\Block\Adminhtml\Csblock */ class Edit extends \Magento\Backend\Block\Widget\Form\Container { /** * Core registry * * @var \Magento\Framework\Registry */ protected $_coreRegistry = null; /** * @param \Magento\Backend\Block\Widget\Context $context * @param \Magento\Framework\Registry $registry * @param array $data */ public function __construct( \Magento\Backend\Block\Widget\Context $context, \Magento\Framework\Registry $registry, array $data = [] ) { $this->_coreRegistry = $registry; parent::__construct($context, $data); } /** * @return void */ protected function _construct() { $this->_objectId = 'id'; $this->_blockGroup = 'Aheadworks_Csblock'; $this->_controller = 'adminhtml_csblock'; $this->setId('csblock_edit'); parent::_construct(); /* @var $model \Aheadworks\Csblock\Model\Csblock */ $model = $this->_coreRegistry->registry('aw_csblock_model'); if ($model && $model->getId()) { $this->buttonList->update('save', 'class_name', \Magento\Backend\Block\Widget\Button\SplitButton::class); $this->buttonList->update('save', 'options', $this->_getSaveButtonOptions()); } else { $this->buttonList->update('save', 'data_attribute', $this->getDataAttribute('save')); } $this->buttonList->add( 'save_and_continue', [ 'label' => __('Save and Continue Edit'), 'class' => 'save', 'data_attribute' => $this->getDataAttribute('saveAndContinueEdit') ], 0 ); } /** * Get save button options * * @return array */ protected function _getSaveButtonOptions() { return [ [ 'label' => __('Save as New'), 'data_attribute' => $this->getDataAttribute('saveAndNew'), 'default' => false ] ]; } /** * Get data attribute * * @param string $event * @return array */ private function getDataAttribute($event) { return [ 'mage-init' => [ 'awCsbButton' => ['event' => $event, 'target' => '#edit_form'] ], ]; } /** * Get URL for back (reset) button * * @return string */ public function getBackUrl() { return $this->getUrl('*/csblock/'); } /** * Get URL for delete button * * @return string */ public function getDeleteUrl() { return $this->getUrl('*/csblock/delete', ['_current' => true]); } /** * Prepare layout * * @return \Magento\Framework\View\Element\AbstractBlock */ protected function _prepareLayout() { $this->_formScripts[] = ' require([ "jquery", "mage/mage" ], function($){ var $form = $("#edit_form"); $("#save-button").on("click", function(){ $(this).attr("disabled", "disabled"); }); $form.mage("form", { handlersData: { saveAndNew: { action: { args: {back: "new"} } }, } }); });'; return parent::_prepareLayout(); } }