/** * {@inheritdoc} */ protected function _prepareForm() { $form = $this->formFactory->create()->setData(['id' => 'edit_form', 'action' => $this->getUrl('*/*/save', ['id' => $this->getRequest()->getParam('id')]), 'method' => 'post', 'enctype' => 'multipart/form-data']); $form->setUseContainer(true); $this->setForm($form); return parent::_prepareForm(); }
/** * {@inheritdoc} */ protected function _prepareForm() { /** @var \Mirasvit\Search\Model\Index $model */ $model = $this->registry->registry('current_model'); $form = $this->formFactory->create(); $fieldset = $form->addFieldset('base_fieldset', ['legend' => __('General Information'), 'class' => 'fieldset-wide']); if ($model->getId()) { $fieldset->addField('index_id', 'hidden', ['name' => 'id']); } $fieldset->addField('title', 'text', ['name' => 'title', 'label' => __('Title'), 'required' => true]); if ($model->getId()) { $model->setData('index_label', $model->getIndexInstance()->toString()); $fieldset->addField('index_label', 'label', ['label' => __('Index')]); } else { $fieldset->addField('code', 'select', ['label' => __('Index'), 'name' => 'code', 'required' => true, 'values' => $this->sourceIndex->toOptionArray(true)]); } $fieldset->addField('position', 'text', ['name' => 'position', 'label' => __('Position'), 'required' => true]); $fieldset->addField('is_active', 'select', ['label' => __('Status'), 'name' => 'is_active', 'required' => true, 'options' => ['1' => __('Enabled'), '0' => __('Disabled')]]); if (!$model->getId()) { $model->setData('is_active', '1'); } $form->setValues($model->getData()); $this->setForm($form); return parent::_prepareForm(); }
/** * {@inheritdoc} */ protected function _prepareForm() { $form = $this->formFactory->create(['data' => ['id' => 'edit_form', 'action' => $this->getData('action'), 'method' => 'post']]); $form->setUseContainer(true); $this->setForm($form); return parent::_prepareForm(); }
/** * @return $this * * @throws \Magento\Framework\Exception\LocalizedException */ protected function _prepareForm() { $form = $this->formFactory->create(); $this->setForm($form); /** @var \Mirasvit\Blog\Model\Post $post */ $post = $this->registry->registry('current_model'); $fieldset = $form->addFieldset('tags_fieldset', ['class' => 'blog__post-fieldset', 'legend' => __('Author')]); $fieldset->addField('author_id', 'select', ['name' => 'post[author_id]', 'value' => $post->getAuthorId(), 'values' => $this->authorSource->toOptionArray()]); return parent::_prepareForm(); }
/** * @return $this * * @throws \Magento\Framework\Exception\LocalizedException */ protected function _prepareForm() { $form = $this->formFactory->create(); $this->setForm($form); /** @var \Mirasvit\Blog\Model\Post $post */ $post = $this->registry->registry('current_model'); $fieldset = $form->addFieldset('image_fieldset', ['class' => 'blog__post-fieldset', 'legend' => __('Featured Image')]); $fieldset->addField('featured_image', 'image', ['required' => false, 'name' => 'featured_image', 'value' => $post->getFeaturedImageUrl()]); return parent::_prepareForm(); }
/** * Create a form element with necessary controls * * @return \Magento\DesignEditor\Block\Adminhtml\Editor\Tools\QuickStyles\Header * @throws \Magento\Framework\Exception\LocalizedException */ protected function _prepareForm() { if (!$this->_formId || !$this->_tab) { throw new \Magento\Framework\Exception\LocalizedException(__('We found an invalid block of class "%1". Please define the required properties.', get_class($this))); } $form = $this->_formBuilder->create(['id' => $this->_formId, 'action' => '#', 'method' => 'post', 'tab' => $this->_tab, 'theme' => $this->_themeContext->getStagingTheme(), 'parent_theme' => $this->_themeContext->getEditableTheme()->getParentTheme()]); $form->setUseContainer(true); $this->setForm($form); parent::_prepareForm(); return $this; }
/** * @return $this * * @throws \Magento\Framework\Exception\LocalizedException */ protected function _prepareForm() { $form = $this->formFactory->create(); $this->setForm($form); /** @var \Mirasvit\Blog\Model\Post $post */ $post = $this->registry->registry('current_model'); $fieldset = $form->addFieldset('categories_fieldset', ['class' => 'blog__post-fieldset', 'legend' => __('Categories')]); $collection = $this->categoryCollectionFactory->create()->addAttributeToSelect(['name']); $fieldset->addField('category_ids', 'checkboxes', ['name' => 'post[category_ids][]', 'value' => $post->getCategoryIds(), 'values' => $collection->toOptionArray()]); return parent::_prepareForm(); }
/** * @return $this * * @throws \Magento\Framework\Exception\LocalizedException */ protected function _prepareForm() { $form = $this->formFactory->create(); $this->setForm($form); /** @var \Mirasvit\Blog\Model\Post $post */ $post = $this->registry->registry('current_model'); $fieldset = $form->addFieldset('publish_fieldset', ['class' => 'blog__post-fieldset', 'legend' => __('Publish')]); $fieldset->addField('status', 'select', ['label' => __('Status'), 'name' => 'post[status]', 'value' => $post->getStatus(), 'values' => $this->status->toOptionArray()]); $fieldset->addField('created_at', 'date', ['label' => __('Published on'), 'name' => 'post[created_at]', 'value' => $post->getCreatedAt(), 'date_format' => 'MMM d, y', 'time_format' => 'h:mm a']); $fieldset->addField('is_pinned', 'checkbox', ['label' => __('Pin post at the top'), 'name' => 'post[is_pinned]', 'value' => 1, 'checked' => $post->getIsPinned()]); return parent::_prepareForm(); }
/** * {@inheritdoc} */ protected function _prepareForm() { $form = $this->formFactory->create(); $form->setHtmlIdPrefix('attributes_'); $model = $this->registry->registry('current_model'); if ($model->getId()) { $fieldset = $form->addFieldset('attribute_fieldset', ['legend' => __('Attributes'), 'class' => 'fieldset-wide']); $fieldset->setRenderer($this->getLayout()->createBlock('Mirasvit\\Search\\Block\\Adminhtml\\Index\\Edit\\Renderer\\Attributes')->setIndex($model)); } $form->setValues($model->getData()); $this->setForm($form); return parent::_prepareForm(); }
/** * @return $this * * @throws \Magento\Framework\Exception\LocalizedException */ protected function _prepareForm() { $form = $this->formFactory->create(); $this->setForm($form); /** @var \Mirasvit\Blog\Model\Post $post */ $post = $this->registry->registry('current_model'); $fieldset = $form->addFieldset('edit_fieldset', ['class' => 'blog__post-fieldset']); $fieldset->addField('meta_title', 'text', ['label' => __('Meta Title'), 'name' => 'post[meta_title]', 'value' => $post->getMetaTitle()]); $fieldset->addField('meta_description', 'textarea', ['label' => __('Meta Description'), 'name' => 'post[meta_description]', 'value' => $post->getMetaDescription()]); $fieldset->addField('meta_keywords', 'textarea', ['label' => __('Meta Keywords'), 'name' => 'post[meta_keywords]', 'value' => $post->getMetaKeywords()]); $fieldset->addField('url_key', 'text', ['label' => __('URL Key'), 'name' => 'post[url_key]', 'value' => $post->getUrlKey()]); return parent::_prepareForm(); }
/** * @return $this * * @throws \Magento\Framework\Exception\LocalizedException */ protected function _prepareForm() { $form = $this->formFactory->create(); $this->setForm($form); /** @var \Mirasvit\Blog\Model\Category $category */ $category = $this->registry->registry('current_model'); $fieldset = $form->addFieldset('edit_fieldset', ['legend' => __('Search Engine Optimization')]); $fieldset->addField('url_key', 'text', ['label' => __('URL Key'), 'name' => 'url_key', 'value' => $category->getUrlKey()]); $fieldset->addField('meta_title', 'text', ['label' => __('Meta Title'), 'name' => 'meta_title', 'value' => $category->getMetaTitle()]); $fieldset->addField('meta_description', 'textarea', ['label' => __('Meta Description'), 'name' => 'meta_description', 'value' => $category->getMetaDescription()]); $fieldset->addField('meta_keywords', 'textarea', ['label' => __('Meta Keywords'), 'name' => 'meta_keywords', 'value' => $category->getMetaKeywords()]); return parent::_prepareForm(); }
/** * @return $this * * @throws \Magento\Framework\Exception\LocalizedException */ protected function _prepareForm() { $form = $this->formFactory->create()->setData(['id' => 'edit_form', 'action' => $this->getUrl('*/*/save', ['id' => $this->getRequest()->getParam('id')]), 'method' => 'post', 'enctype' => 'multipart/form-data']); $form->setUseContainer(true); $this->setForm($form); $this->setForm($form); /** @var \Mirasvit\Blog\Model\Author $author */ $author = $this->registry->registry('current_model'); $fieldset = $form->addFieldset('edit_fieldset', ['legend' => __('Author Information')]); if ($author->getId()) { $fieldset->addField('user_id', 'hidden', ['name' => 'user_id', 'value' => $author->getId()]); } $fieldset->addField('display_name', 'text', ['label' => __('Display Name'), 'name' => 'display_name', 'value' => $author->getDisplayName(), 'required' => true]); $fieldset->addField('bio', 'textarea', ['label' => __('Biographical Info'), 'name' => 'bio', 'value' => $author->getBio(), 'required' => false]); return parent::_prepareForm(); }
/** * {@inheritdoc} */ protected function _prepareForm() { $form = $this->formFactory->create(); $form->setHtmlIdPrefix('properties_'); $model = $this->registry->registry('current_model'); if ($model->getId()) { foreach ($model->getIndexInstance()->getFieldsets() as $class) { $fieldset = $this->objectManager->create($class); $fieldset->setId($class)->setLegend('Additional Options')->setIndex($model); $form->addElement($fieldset); } } $form->setValues($model->getData()); $this->setForm($form); return parent::_prepareForm(); }
/** * @return $this * * @throws \Magento\Framework\Exception\LocalizedException */ protected function _prepareForm() { $form = $this->formFactory->create(); $this->setForm($form); /** @var \Mirasvit\Blog\Model\Post $post */ $post = $this->registry->registry('current_model'); $fieldset = $form->addFieldset('edit_fieldset', ['class' => 'blog__post-fieldset']); if ($post->getId()) { $fieldset->addField('entity_id', 'hidden', ['name' => 'post[entity_id]', 'value' => $post->getId()]); } $fieldset->addField('name', 'text', ['label' => __('Title'), 'name' => 'post[name]', 'value' => $post->getName(), 'required' => true]); $editorConfig = $this->wysiwygConfig->getConfig(['tab_id' => $this->getTabId()]); $fieldset->addField('content', 'editor', ['name' => 'post[content]', 'value' => $post->getContent(), 'wysiwyg' => true, 'style' => 'height:35em', 'config' => $editorConfig]); $fieldset->addField('short_content', 'editor', ['label' => __('Excerpt'), 'name' => 'post[short_content]', 'value' => $post->getShortContent(), 'wysiwyg' => true, 'style' => 'height:5em', 'config' => $editorConfig]); return parent::_prepareForm(); }
/** * @return $this * * @throws \Magento\Framework\Exception\LocalizedException */ protected function _prepareForm() { $form = $this->formFactory->create(); $this->setForm($form); /** @var \Mirasvit\Blog\Model\Category $category */ $category = $this->registry->registry('current_model'); $fieldset = $form->addFieldset('edit_fieldset', ['legend' => __('General Information')]); if ($category->getId()) { $fieldset->addField('entity_id', 'hidden', ['name' => 'entity_id', 'value' => $category->getId()]); } $fieldset->addField('name', 'text', ['label' => __('Title'), 'name' => 'name', 'value' => $category->getName(), 'required' => true]); if ($category->getId() != 1) { $categories = $this->categoryCollectionFactory->create()->addAttributeToSelect('name')->toOptionArray(); $fieldset->addField('parent_id', 'radios', ['label' => __('Parent Category'), 'name' => 'parent_id', 'value' => $category->getParentId() ? $category->getParentId() : 1, 'values' => $categories, 'required' => true]); } $fieldset->addField('status', 'select', ['label' => __('Status'), 'name' => 'status', 'value' => $category->getStatus(), 'values' => ['0' => __('Disabled'), '1' => __('Enabled')]]); return parent::_prepareForm(); }
/** * Prepare form before rendering HTML * * @return \Magento\Backend\Block\Widget\Form */ protected function _prepareForm() { $this->_formHelper->addGoogleoptimizerFields($this->getForm(), $this->_getGoogleExperiment()); return parent::_prepareForm(); }