<?php
namespace [VENDOR]\[EXTENSION]\Block\Adminhtml\[CUSTOM]\Edit\Tab;
class Form extends \Magento\Backend\Block\Widget\Form\Generic implements \Magento\Backend\Block\Widget\Tab\TabInterface
{
protected $_wysiwygConfig;
public function __construct(
\Magento\Backend\Block\Template\Context $context,
\Magento\Framework\Registry $registry,
\Magento\Framework\Data\FormFactory $formFactory,
\Magento\Cms\Model\Wysiwyg\Config $wysiwygConfig,
array $data = []
)
{
$this->_wysiwygConfig = $wysiwygConfig;
parent::__construct($context, $registry, $formFactory, $data);
}
protected function _prepareForm()
{
$model = $this->_coreRegistry->registry('EXTENSIONKEY');
/** @var \Magento\Framework\Data\Form $form */
$form = $this->_formFactory->create();
$fieldset = $form->addFieldset('base_fieldset', ['legend' => __('YOUR FORM TITLE')]);
$fieldset->addField('storycontent', 'editor', [
'name' => 'storycontent',
'label' => 'Story Content',
'config' => $this->_wysiwygConfig->getConfig(),
'wysiwyg' => true,
'required' => false,
'after_element_html' => '<small>YOURCOMMENT.</small>',
'value' => $model->getStorycontent()
]);
$this->setForm($form);
return parent::_prepareForm();
}
}
?>
namespace [VENDOR]\[EXTENSION]\Block\Adminhtml\[CUSTOM]\Edit\Tab;
class Form extends \Magento\Backend\Block\Widget\Form\Generic implements \Magento\Backend\Block\Widget\Tab\TabInterface
{
protected $_wysiwygConfig;
public function __construct(
\Magento\Backend\Block\Template\Context $context,
\Magento\Framework\Registry $registry,
\Magento\Framework\Data\FormFactory $formFactory,
\Magento\Cms\Model\Wysiwyg\Config $wysiwygConfig,
array $data = []
)
{
$this->_wysiwygConfig = $wysiwygConfig;
parent::__construct($context, $registry, $formFactory, $data);
}
protected function _prepareForm()
{
$model = $this->_coreRegistry->registry('EXTENSIONKEY');
/** @var \Magento\Framework\Data\Form $form */
$form = $this->_formFactory->create();
$fieldset = $form->addFieldset('base_fieldset', ['legend' => __('YOUR FORM TITLE')]);
$fieldset->addField('storycontent', 'editor', [
'name' => 'storycontent',
'label' => 'Story Content',
'config' => $this->_wysiwygConfig->getConfig(),
'wysiwyg' => true,
'required' => false,
'after_element_html' => '<small>YOURCOMMENT.</small>',
'value' => $model->getStorycontent()
]);
$this->setForm($form);
return parent::_prepareForm();
}
}
?>
No comments:
Post a Comment