Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Edit.php
Go to the documentation of this file.
1 <?php
7 
14 class Edit extends \Magento\Backend\Block\Widget\Form\Container
15 {
21  protected $_coreRegistry = null;
22 
28  public function __construct(
29  \Magento\Backend\Block\Widget\Context $context,
30  \Magento\Framework\Registry $registry,
31  array $data = []
32  ) {
33  $this->_coreRegistry = $registry;
34  parent::__construct($context, $data);
35  }
36 
42  protected function _construct()
43  {
44  $this->_objectId = 'variable_id';
45  $this->_blockGroup = 'Magento_Variable';
46  $this->_controller = 'system_variable';
47 
48  parent::_construct();
49  }
50 
56  public function getVariable()
57  {
58  return $this->_coreRegistry->registry('current_variable');
59  }
60 
67  protected function _preparelayout()
68  {
69  $this->addButton(
70  'save_and_edit',
71  [
72  'label' => __('Save and Continue Edit'),
73  'class' => 'save',
74  'data_attribute' => [
75  'mage-init' => ['button' => ['event' => 'saveAndContinueEdit', 'target' => '#edit_form']],
76  ]
77  ],
78  100
79  );
80  if (!$this->getVariable()->getId()) {
81  $this->removeButton('delete');
82  }
83  return parent::_prepareLayout();
84  }
85 
91  public function getFormHtml()
92  {
93  return parent::getFormHtml();
94  }
95 
101  public function getHeaderText()
102  {
103  if ($this->getVariable()->getId()) {
104  return __('Custom Variable "%1"', $this->escapeHtml($this->getVariable()->getName()));
105  } else {
106  return __('New Custom Variable');
107  }
108  }
109 
115  public function getValidationUrl()
116  {
117  return $this->getUrl('adminhtml/*/validate', ['_current' => true]);
118  }
119 
125  public function getSaveUrl()
126  {
127  return $this->getUrl('adminhtml/*/save', ['_current' => true, 'back' => null]);
128  }
129 
135  public function getSaveAndContinueUrl()
136  {
137  return $this->getUrl('adminhtml/*/save', ['_current' => true, 'back' => 'edit']);
138  }
139 }
__construct(\Magento\Backend\Block\Widget\Context $context, \Magento\Framework\Registry $registry, array $data=[])
Definition: Edit.php:28
__()
Definition: __.php:13
addButton($buttonId, $data, $level=0, $sortOrder=0, $region='toolbar')
Definition: Container.php:85