Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Widget.php
Go to the documentation of this file.
1 <?php
8 
15 class Widget extends \Magento\Backend\Block\Widget\Form\Container
16 {
22  protected function _construct()
23  {
24  parent::_construct();
25 
26  $this->_blockGroup = 'Magento_Widget';
27  $this->_controller = 'adminhtml';
28  $this->_mode = 'widget';
29  $this->_headerText = __('Widget Insertion');
30 
31  $saveButtonClass = 'action-primary add-widget';
32  $this->removeButton('back');
33  if ($this->getRequest()->getParam('mode') === 'new') {
34  $this->buttonList->update('save', 'label', __('Insert Widget'));
35  $saveButtonClass .= ' disabled';
36  }
37  $this->buttonList->update('save', 'class', $saveButtonClass);
38  $this->buttonList->update('save', 'id', 'insert_button');
39  $this->buttonList->update('save', 'onclick', 'wWidget.insertWidget()');
40  $this->buttonList->update('save', 'region', 'toolbar');
41  $this->buttonList->update('save', 'data_attribute', []);
42  $this->buttonList->update('reset', 'label', __('Cancel'));
43  $this->buttonList->update('reset', 'onclick', 'wWidget.closeModal()');
44 
45  $this->_formScripts[] = <<<EOJS
46 require(['mage/adminhtml/wysiwyg/widget'], function() {
47  wWidget = new WysiwygWidget.Widget(
48  'widget_options_form',
49  'select_widget_type',
50  'widget_options',
51  '{$this->getUrl('adminhtml/*/loadOptions')}',
52  '{$this->escapeJs($this->getRequest()->getParam('widget_target_id'))}'
53  );
54 });
55 EOJS;
56  }
57 }
__()
Definition: __.php:13