/** * @param ContextInterface $context * @param FormFactory $formFactory * @param ConfigInterface $wysiwygConfig * @param array $components * @param array $data * @param array $config */ public function __construct(ContextInterface $context, FormFactory $formFactory, ConfigInterface $wysiwygConfig, array $components = [], array $data = [], array $config = []) { $wysiwygConfigData = isset($config['wysiwygConfigData']) ? $config['wysiwygConfigData'] : []; $this->form = $formFactory->create(); $this->editor = $this->form->addField($context->getNamespace() . '_' . $data['name'], 'Magento\\Framework\\Data\\Form\\Element\\Editor', ['force_load' => true, 'rows' => 20, 'name' => $data['name'], 'config' => $wysiwygConfig->getConfig($wysiwygConfigData), 'wysiwyg' => isset($config['wysiwyg']) ? $config['wysiwyg'] : null]); $data['config']['content'] = $this->editor->getElementHtml(); parent::__construct($context, $components, $data); }
/** * Wysiwyg constructor. * @param ContextInterface $context * @param Form $form * @param EditorElement $editorElement * @param ConfigInterface $wysiwygConfig * @param array $components * @param array $data */ public function __construct(ContextInterface $context, Form $form, EditorElement $editorElement, ConfigInterface $wysiwygConfig, array $components = [], array $data = []) { $this->editorElement = $editorElement; $this->editorElement->setForm($form); $this->editorElement->setData('force_load', true); $this->editorElement->setData('rows', 20); $this->editorElement->setData('name', $data['name']); $this->editorElement->setData('html_id', $data['name'] . 'Editor'); $this->editorElement->setConfig($wysiwygConfig->getConfig()); $data['config']['content'] = $editorElement->getElementHtml(); parent::__construct($context, $components, $data); }
/** * Prepare component configuration * * @return void */ public function prepare() { $size = abs((int) $this->getData('config/size')); $validation = [$this->getData('config/validation')]; while ($size--) { $identifier = $this->getName() . '_' . $size; $arguments = ['data' => ['name' => $identifier, 'config' => ['dataScope' => $size, 'dataType' => static::DATA_TYPE, 'formElement' => static::FORM_ELEMENT, 'sortOrder' => $size]]]; if (!empty($validation[$size])) { $arguments['data']['config']['validation'] = $validation[$size]; } $component = $this->uiComponentFactory->create($identifier, Field::NAME, $arguments); $component->prepare(); $this->components[$identifier] = $component; } parent::prepare(); }
/** * Prepare component configuration * * @return void */ public function prepare() { $config = $this->getData('config'); if (isset($this->options)) { if (!isset($config['options'])) { $config['options'] = []; } if ($this->options instanceof OptionSourceInterface) { $options = $this->options->toOptionArray(); } else { $options = array_values($this->options); } $config['options'] = array_values(array_merge_recursive($options, $config['options'])); } $this->setData('config', (array) $config); parent::prepare(); }
/** * Prepare component configuration * * @return void */ public function prepare() { parent::prepare(); $config = $this->getData('config'); if (isset($this->options)) { if (!isset($config['options'])) { $config['options'] = []; } if ($this->options instanceof OptionSourceInterface) { $options = $this->options->toOptionArray(); } else { $options = array_values($this->options); } $config['options'] = array_values(array_merge_recursive($options, $config['options'])); } $this->setData('config', (array) $config); $jsConfig = $this->getConfiguration($this, Input::NAME); $this->getContext()->addComponentDefinition($this->getComponentName(), $jsConfig); }