আমি একটি নতুন ফর্ম উপাদান টাইপ যুক্ত করেছি Company\Module\Data\Form\Element\PdfButton, যখন এটি তৈরি হয় version EE 2.0.7এবং Magento\Catalog\Block\Adminhtml\Product\Edit\Tabsপণ্য সম্পাদনা প্রশাসক পৃষ্ঠার কাস্টম ট্যাবে (ওভাররাইড করে যুক্ত ) এই উপাদানটি ব্যবহার করা হয় ।
Magento EE 2.1 এ আপগ্রেড করার পরে, কাস্টম ট্যাবটি অদৃশ্য। এটি প্রদর্শিত হওয়ার জন্য, আমি পণ্য পৃষ্ঠাতে একটি নতুন ট্যাব তৈরি করতে একটি সংশোধক যুক্ত করেছি। আমি ভেন্ডর ফাইলটিতে মডিফায়ারটি অনুলিপি করে সফলভাবে একটি নতুন ট্যাব যুক্ত করেছি এবং এটি আমার মডিউলটিতে ইনজেক্ট করেছি।
তবে, যখন আমি আমার কাস্টম উপাদানটি ব্যবহার করতে চাই। সুতরাং, মেটা অ্যারের বাচ্চাদের ক্ষেত্রে, আমি নিম্নলিখিত কোডটি যুক্ত করেছি:
$children[$website['id']] = [
'arguments' => [
'data' => [
'config' => [
'dataType' => Form\Element\DataType\Number::NAME,
'componentType' => Form\Field::NAME,
'formElement' => Form\Element\Wysiwyg2::NAME,
'description' => __($website['name']),
'tooltip' => $tooltip,
'sortOrder' => $sortOrder,
'dataScope' => 'website_ids.' . $website['id'],
'label' => "Pdf Upload",
'valueMap' => [
'true' => (string)$website['id'],
'false' => '0',
],
'value' => $isChecked ? (string)$website['id'] : '0',
],
],
],
];
এর পরে, আমি অনুলিপি করে Form\Element\Wysiwygএবং এটি হিসাবে আটকান Form\Element\Wysiwyg2। ইন Wysiwyg2 ক্লাস:
<?php
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Ui\Component\Form\Element;
use Magento\Framework\Data\Form\Element\Editor;
use Magento\Framework\Data\Form;
use Magento\Framework\Data\FormFactory;
use Magento\Framework\DataObject;
use Magento\Framework\View\Element\UiComponent\ContextInterface;
use Magento\Ui\Component\Wysiwyg\ConfigInterface;
/**
* Class Input
*/
class Wysiwyg2 extends AbstractElement
{
const NAME = 'wysiwyg2';
/**
* @var Form
*/
protected $form;
/**
* @var Editor
*/
protected $editor;
/**
* @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);
}
/**
* Get component name
*
* @return string
*/
public function getComponentName()
{
return static::NAME;
}}
তবে একটি ত্রুটি আছে এবং আমি জানি না যে সেখানে নামটি আমার যুক্ত করা উচিত।
1 exception(s):
Exception #0 (Magento\Framework\Exception\LocalizedException): The requested component ("wysiwyg2") is not found. Before using, you must add the implementation.
Exception #0 (Magento\Framework\Exception\LocalizedException): The requested component ("wysiwyg2") is not found. Before using, you must add the implementation.
#0 /var/www/vhosts/plchk/vendor/magento/module-ui/Model/Manager.php(207): Magento\Framework\View\Element\UiComponent\Config\Provider\Component\Definition->getComponentData('wysiwyg2')
#1 /var/www/vhosts/plchk/vendor/magento/framework/View/Element/UiComponentFactory.php(187): Magento\Ui\Model\Manager->createRawComponentData('wysiwyg2')
#2 /var/www/vhosts/plchk/vendor/magento/module-ui/Component/Form/Field.php(82): Magento\Framework\View\Element\UiComponentFactory->create(1, 'wysiwyg2', Array)
#3 /var/www/vhosts/plchk/vendor/magento/framework/View/Layout/Generator/UiComponent.php(148): Magento\Ui\Component\Form\Field->prepare()
#4 /var/www/vhosts/plchk/vendor/magento/framework/View/Layout/Generator/UiComponent.php(145): Magento\Framework\View\Layout\Generator\UiComponent->prepareComponent(Object(Magento\Ui\Component\Form\Field))