/** * Prepare form * * @return $this */ protected function _prepareForm() { $model = $this->_coreRegistry->registry('lists'); /** @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->getId()) { $fieldset->addField('id', 'hidden', ['name' => 'id']); } $fieldset->addField('title', 'text', ['name' => 'title', 'label' => __('Block Title'), 'title' => __('Block Title'), 'required' => true]); $fieldset->addField('status', 'select', ['label' => __('Status'), 'title' => __('Status'), 'name' => 'status', 'required' => true, 'options' => $this->_status->getOptionArray()]); if (!$model->getId()) { $model->setData('status', '1'); } $fieldset->addField('short_summary', 'editor', ['name' => 'short_summary', 'label' => __('Summary'), 'title' => __('Summary'), 'style' => 'height:36em', 'required' => true, 'config' => $this->_wysiwygConfig->getConfig()]); $form->setValues($model->getData()); $form->setUseContainer(true); $this->setForm($form); return parent::_prepareForm(); }
/** * Prepare form * * @return $this * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ protected function _prepareForm() { /* @var $model \SR\Weblog\Model\BlogPosts */ $model = $this->_coreRegistry->registry('lists'); $isElementDisabled = false; /** @var \Magento\Framework\Data\Form $form */ $form = $this->_formFactory->create(); //$form->setHtmlIdPrefix('page_'); $fieldset = $form->addFieldset('base_fieldset', ['legend' => __('Information')]); if ($model->getId()) { $fieldset->addField('id', 'hidden', ['name' => 'id']); } $fieldset->addField('title', 'text', ['name' => 'title', 'label' => __('Title'), 'title' => __('Title'), 'required' => true, 'disabled' => $isElementDisabled, 'value' => 'abc']); if (!$model->getId()) { $model->setData('status', $isElementDisabled ? '0' : '1'); } $fieldset->addField('status', 'select', ['label' => __('Status'), 'title' => __('Status'), 'name' => 'status', 'required' => true, 'options' => $this->_status->getOptionArray(), 'disabled' => $isElementDisabled]); $fieldset->addField('short_summary', 'editor', ['name' => 'short_summary', 'label' => __('Summary'), 'title' => __('Summary'), 'style' => 'height:36em', 'required' => true, 'config' => $this->_wysiwygConfig->getConfig()]); $fieldset->addField('in_lists_grid', 'hidden', ['name' => 'in_lists_grid', 'id' => 'in_lists_gridz']); $fieldset->addField('in_lists_grid_old', 'hidden', ['name' => 'in_lists_grid_old']); $dateFormat = $this->_localeDate->getDateFormat(\IntlDateFormatter::SHORT); /* $fieldset->addField( 'created_at', 'date', [ 'name' => 'created_at', 'label' => __('Created Date'), 'date_format' => $dateFormat, 'disabled' => $isElementDisabled, 'class' => 'validate-date validate-date-range date-range-custom_theme-from' ] ); */ $form->setValues($model->getData()); $this->setForm($form); return parent::_prepareForm(); }