-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Closed
Description
An event on a backend CMS page form creation:
| $this->_eventManager->dispatch('adminhtml_cms_page_edit_tab_content_prepare_form', ['form' => $form]); |
No any event on a backend CMS block form creation:
magento2/app/code/Magento/Cms/Block/Adminhtml/Block/Edit/Form.php
Lines 61 to 158 in c743dec
| protected function _prepareForm() | |
| { | |
| $model = $this->_coreRegistry->registry('cms_block'); | |
| /** @var \Magento\Framework\Data\Form $form */ | |
| $form = $this->_formFactory->create( | |
| ['data' => ['id' => 'edit_form', 'action' => $this->getData('action'), 'method' => 'post']] | |
| ); | |
| $form->setHtmlIdPrefix('block_'); | |
| $fieldset = $form->addFieldset( | |
| 'base_fieldset', | |
| ['legend' => __('General Information'), 'class' => 'fieldset-wide'] | |
| ); | |
| if ($model->getBlockId()) { | |
| $fieldset->addField('block_id', 'hidden', ['name' => 'block_id']); | |
| } | |
| $fieldset->addField( | |
| 'title', | |
| 'text', | |
| ['name' => 'title', 'label' => __('Block Title'), 'title' => __('Block Title'), 'required' => true] | |
| ); | |
| $fieldset->addField( | |
| 'identifier', | |
| 'text', | |
| [ | |
| 'name' => 'identifier', | |
| 'label' => __('Identifier'), | |
| 'title' => __('Identifier'), | |
| 'required' => true, | |
| 'class' => 'validate-xml-identifier' | |
| ] | |
| ); | |
| /* Check is single store mode */ | |
| if (!$this->_storeManager->isSingleStoreMode()) { | |
| $field = $fieldset->addField( | |
| 'store_id', | |
| 'multiselect', | |
| [ | |
| 'name' => 'stores[]', | |
| 'label' => __('Store View'), | |
| 'title' => __('Store View'), | |
| 'required' => true, | |
| 'values' => $this->_systemStore->getStoreValuesForForm(false, true) | |
| ] | |
| ); | |
| $renderer = $this->getLayout()->createBlock( | |
| 'Magento\Backend\Block\Store\Switcher\Form\Renderer\Fieldset\Element' | |
| ); | |
| $field->setRenderer($renderer); | |
| } else { | |
| $fieldset->addField( | |
| 'store_id', | |
| 'hidden', | |
| ['name' => 'stores[]', 'value' => $this->_storeManager->getStore(true)->getId()] | |
| ); | |
| $model->setStoreId($this->_storeManager->getStore(true)->getId()); | |
| } | |
| $fieldset->addField( | |
| 'is_active', | |
| 'select', | |
| [ | |
| 'label' => __('Status'), | |
| 'title' => __('Status'), | |
| 'name' => 'is_active', | |
| 'required' => true, | |
| 'options' => ['1' => __('Enabled'), '0' => __('Disabled')] | |
| ] | |
| ); | |
| if (!$model->getId()) { | |
| $model->setData('is_active', '1'); | |
| } | |
| $fieldset->addField( | |
| 'content', | |
| 'editor', | |
| [ | |
| 'name' => 'content', | |
| 'label' => __('Content'), | |
| 'title' => __('Content'), | |
| 'style' => 'height:36em', | |
| 'required' => true, | |
| 'config' => $this->_wysiwygConfig->getConfig() | |
| ] | |
| ); | |
| $form->setValues($model->getData()); | |
| $form->setUseContainer(true); | |
| $this->setForm($form); | |
| return parent::_prepareForm(); | |
| } |