public function testSetFormNoCustomAttributes() { $baseUrl = 'base_url'; $this->dataForm->expects($this->once())->method('setParent')->with($this->model)->willReturnSelf(); $this->dataForm->expects($this->once())->method('setBaseUrl')->with($baseUrl)->willReturnSelf(); $this->urlBuilder->expects($this->once())->method('getBaseUrl')->willReturn($baseUrl); $this->assertEquals($this->model, $this->model->setForm($this->dataForm)); }
/** * {@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(); }
/** * {@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()->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(); }
public function __construct(\Magento\Backend\Block\Widget\Context $context, \Magento\Framework\ObjectManagerInterface $manager, array $data = []) { $this->_request = $context->getRequest(); $mailId = $this->_request->getParam('id'); $this->_mail = $manager->get('\\Shockwavemk\\Mail\\Base\\Model\\Mail'); $this->_mail->load($mailId); parent::__construct($context, $data); }
/** * @param \Magento\Backend\Block\Template\Context $context * @param \Magento\Framework\Acl\RootResource $rootResource * @param \Magento\Authorization\Model\ResourceModel\Rules\CollectionFactory $rulesCollectionFactory * @param \Magento\Authorization\Model\Acl\AclRetriever $aclRetriever * @param \Magento\Framework\Acl\AclResource\ProviderInterface $aclResourceProvider * @param \Magento\Integration\Helper\Data $integrationData * @param array $data */ public function __construct(\Magento\Backend\Block\Template\Context $context, \Magento\Authorization\Model\Acl\AclRetriever $aclRetriever, \Magento\Framework\Acl\RootResource $rootResource, \Magento\Authorization\Model\ResourceModel\Rules\CollectionFactory $rulesCollectionFactory, \Magento\Framework\Acl\AclResource\ProviderInterface $aclResourceProvider, \Magento\Integration\Helper\Data $integrationData, array $data = []) { $this->_aclRetriever = $aclRetriever; $this->_rootResource = $rootResource; $this->_rulesCollectionFactory = $rulesCollectionFactory; $this->_aclResourceProvider = $aclResourceProvider; $this->_integrationData = $integrationData; parent::__construct($context, $data); }
/** * @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(); }
/** * @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(); }
/** * 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\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(); $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()->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(); }
/** * @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(); }
/** * {@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\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(); }
/** * @param FormFactory $formFactory * @param Registry $registry * @param Context $context */ public function __construct(FormFactory $formFactory, Registry $registry, Context $context) { $this->formFactory = $formFactory; $this->registry = $registry; parent::__construct($context); }
/** * Class constructor * * @return void */ protected function _construct() { parent::_construct(); $rid = $this->_request->getParam('rid', false); $this->setSelectedResources($this->_aclRetriever->getAllowedResourcesByRole($rid)); }
/** * @param \Magento\Backend\Block\Template\Context $context * @param \Magento\Framework\Registry $registry * @param array $data */ public function __construct(\Magento\Backend\Block\Template\Context $context, \Magento\Framework\Registry $registry, array $data = array()) { $this->_coreRegistry = $registry; parent::__construct($context, $data); }
/** * @param \Magento\Backend\Block\Template\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\Data\FormFactory $formFactory * @param array $data */ public function __construct(\Magento\Backend\Block\Template\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\Data\FormFactory $formFactory, array $data = []) { $this->_coreRegistry = $registry; $this->_formFactory = $formFactory; parent::__construct($context, $data); }
public function __construct(\Magento\Backend\Block\Widget\Context $context, \Magento\Framework\ObjectManagerInterface $manager, array $data = []) { parent::__construct($context, $data); }
/** * Constructor. Initialization required variables for class instance. */ public function _construct() { $this->_blockGroup = 'Dotdigitalgroup\\Email'; $this->_controller = 'adminhtml_studio'; parent::_construct(); }
/** * Class constructor * * @return void */ protected function _construct() { parent::_construct(); $rid = $this->_request->getParam('rid', false); $acl = $this->_aclBuilder->getAcl(); $rulesSet = $this->_rulesCollectionFactory->create()->getByRoles($rid)->load(); $selectedResourceIds = array(); foreach ($rulesSet->getItems() as $item) { $itemResourceId = $item->getResource_id(); if ($acl->has($itemResourceId) && $item->getPermission() == 'allow') { $selectedResourceIds[] = $itemResourceId; } } $this->setSelectedResources($selectedResourceIds); }
/** * Prepares layout * * @return \Magento\Framework\View\Element\AbstractBlock */ protected function _prepareLayout() { $this->getToolbar()->addChild('save_button', 'Magento\\Backend\\Block\\Widget\\Button', ['label' => __('Save Currency Symbols'), 'class' => 'save primary save-currency-symbols', 'data_attribute' => ['mage-init' => ['button' => ['event' => 'save', 'target' => '#currency-symbols-form']]]]); return parent::_prepareLayout(); }
/** * Prepare form before rendering HTML * * @return \Magento\Backend\Block\Widget\Form */ protected function _prepareForm() { $this->_formHelper->addGoogleoptimizerFields($this->getForm(), $this->_getGoogleExperiment()); return parent::_prepareForm(); }
/** * @param \Magento\Backend\Block\Template\Context $context * @param \Magento\Framework\Url\EncoderInterface $urlEncoder * @param array $data */ public function __construct(\Magento\Backend\Block\Template\Context $context, \Magento\DesignEditor\Helper\Data $urlEncoder, array $data = []) { $this->urlEncoder = $urlEncoder; parent::__construct($context, $data); }
/** * @param \Magento\Framework\Data\FormFactory $formFactory * @param \Magento\Backend\Block\Widget\Context $context * @param array $data */ public function __construct(\Magento\Framework\Data\FormFactory $formFactory, \Magento\Backend\Block\Widget\Context $context, array $data = []) { $this->formFactory = $formFactory; $this->context = $context; parent::__construct($context, $data); }