37 \
Magento\Framework\Json\EncoderInterface $jsonEncoder,
38 \
Magento\Framework\Data\
Form\Element\Factory $elementFactory,
41 $this->_jsonEncoder = $jsonEncoder;
42 $this->_elementFactory = $elementFactory;
43 parent::__construct($context,
$data);
53 return $this->
_getData(
'source_url');
73 if ($this->
_getData(
'config') instanceof \
Magento\Framework\DataObject) {
77 $configArray = $this->
_getData(
'config');
78 $config = new \Magento\Framework\DataObject();
80 if (!is_array($configArray)) {
85 if (isset($configArray[
'label'])) {
86 $config->setData(
'label',
__($configArray[
'label']));
90 $buttons = [
'open' =>
__(
'Choose...'),
'close' =>
__(
'Close')];
91 if (isset($configArray[
'button']) && is_array($configArray[
'button'])) {
92 foreach ($configArray[
'button'] as
$id =>
$label) {
118 return $this->
_getData(
'fieldset_id');
129 return $this->
hasData(
'hidden_enabled') ? (bool)$this->
_getData(
'hidden_enabled') :
true;
146 $chooser = $fieldset->addField(
149 [
'label' =>
$config->getLabel() ?
$config->getLabel() :
'',
'value_class' =>
'value2']
153 $hidden = $this->_elementFactory->create(
'hidden', [
'data' =>
$element->getData()]);
154 $hidden->setId(
"{$chooserId}value")->setForm(
$element->getForm());
156 $hidden->addClass(
'required-entry');
158 $hiddenHtml = $hidden->getElementHtml();
162 $buttons =
$config->getButtons();
163 $chooseButton = $this->
getLayout()->createBlock(
164 \
Magento\Backend\Block\Widget\Button::class
168 $chooserId .
'control' 174 $chooserId .
'.choose()' 178 $chooser->setData(
'after_element_html', $hiddenHtml . $chooseButton->toHtml());
181 $configJson = $this->_jsonEncoder->encode(
$config->getData());
183 <label class="widget-option-label" id="' .
186 ($this->getLabel() ? $this->
escapeHtml($this->getLabel()) :
__(
192 'advice-container" class="hidden"></div> 194 require(["prototype", "mage/adminhtml/wysiwyg/widget"], function(){ 197 var instantiateChooser = function() { 200 ' = new WysiwygWidget.chooser( 216 'value").advaiceContainer = "' .
222 jQuery(instantiateChooser);
escapeHtml($data, $allowedTags=null)