Пример #1
0
 /**
  * Adding product form elements for editing attribute
  *
  * @return $this
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 protected function _prepareForm()
 {
     $attributeObject = $this->getAttributeObject();
     $form = $this->_formFactory->create(['data' => ['id' => 'edit_form', 'action' => $this->getData('action'), 'method' => 'post']]);
     $fieldset = $form->addFieldset('advanced_fieldset', ['legend' => __('Advanced Attribute Properties'), 'collapsable' => true]);
     $yesno = $this->_yesNo->toOptionArray();
     $validateClass = sprintf('validate-code validate-length maximum-length-%d', \Magento\Eav\Model\Entity\Attribute::ATTRIBUTE_CODE_MAX_LENGTH);
     $fieldset->addField('attribute_code', 'text', ['name' => 'attribute_code', 'label' => __('Attribute Code'), 'title' => __('Attribute Code'), 'note' => __('This is used internally. Make sure you don\'t use spaces or more than %1 symbols.', \Magento\Eav\Model\Entity\Attribute::ATTRIBUTE_CODE_MAX_LENGTH), 'class' => $validateClass]);
     $fieldset->addField('default_value_text', 'text', ['name' => 'default_value_text', 'label' => __('Default Value'), 'title' => __('Default Value'), 'value' => $attributeObject->getDefaultValue()]);
     $fieldset->addField('default_value_yesno', 'select', ['name' => 'default_value_yesno', 'label' => __('Default Value'), 'title' => __('Default Value'), 'values' => $yesno, 'value' => $attributeObject->getDefaultValue()]);
     $dateFormat = $this->_localeDate->getDateFormat(\IntlDateFormatter::SHORT);
     $fieldset->addField('default_value_date', 'date', ['name' => 'default_value_date', 'label' => __('Default Value'), 'title' => __('Default Value'), 'value' => $attributeObject->getDefaultValue(), 'date_format' => $dateFormat]);
     $fieldset->addField('default_value_textarea', 'textarea', ['name' => 'default_value_textarea', 'label' => __('Default Value'), 'title' => __('Default Value'), 'value' => $attributeObject->getDefaultValue()]);
     $fieldset->addField('is_unique', 'select', ['name' => 'is_unique', 'label' => __('Unique Value'), 'title' => __('Unique Value (not shared with other products)'), 'note' => __('Not shared with other products'), 'values' => $yesno]);
     $fieldset->addField('frontend_class', 'select', ['name' => 'frontend_class', 'label' => __('Input Validation for Store Owner'), 'title' => __('Input Validation for Store Owner'), 'values' => $this->_eavData->getFrontendClasses($attributeObject->getEntityType()->getEntityTypeCode())]);
     if ($attributeObject->getId()) {
         $form->getElement('attribute_code')->setDisabled(1);
         if (!$attributeObject->getIsUserDefined()) {
             $form->getElement('is_unique')->setDisabled(1);
         }
     }
     $scopes = [\Magento\Catalog\Model\Resource\Eav\Attribute::SCOPE_STORE => __('Store View'), \Magento\Catalog\Model\Resource\Eav\Attribute::SCOPE_WEBSITE => __('Website'), \Magento\Catalog\Model\Resource\Eav\Attribute::SCOPE_GLOBAL => __('Global')];
     if ($attributeObject->getAttributeCode() == 'status' || $attributeObject->getAttributeCode() == 'tax_class_id') {
         unset($scopes[\Magento\Catalog\Model\Resource\Eav\Attribute::SCOPE_STORE]);
     }
     $fieldset->addField('is_global', 'select', ['name' => 'is_global', 'label' => __('Scope'), 'title' => __('Scope'), 'note' => __('Declare attribute value saving scope'), 'values' => $scopes], 'attribute_code');
     $this->_eventManager->dispatch('product_attribute_form_build', ['form' => $form]);
     if ($attributeObject->getId() && !$attributeObject->getIsUserDefined()) {
         $form->getElement('is_global')->setDisabled(1);
     }
     $this->setForm($form);
     return $this;
 }
Пример #2
0
 /**
  * Prepare form
  *
  * @return $this
  */
 protected function _prepareForm()
 {
     /** @var \Mageplaza\Blog\Model\Topic $topic */
     $topic = $this->_coreRegistry->registry('mageplaza_blog_topic');
     $form = $this->_formFactory->create();
     $form->setHtmlIdPrefix('topic_');
     $form->setFieldNameSuffix('topic');
     $fieldset = $form->addFieldset('base_fieldset', ['legend' => __('Topic Information'), 'class' => 'fieldset-wide']);
     if ($topic->getId()) {
         $fieldset->addField('topic_id', 'hidden', ['name' => 'topic_id']);
     }
     $fieldset->addField('name', 'text', ['name' => 'name', 'label' => __('Name'), 'title' => __('Name'), 'required' => true]);
     $fieldset->addField('description', 'editor', ['name' => 'description', 'label' => __('Description'), 'title' => __('Description'), 'config' => $this->wysiwygConfig->getConfig()]);
     $fieldset->addField('enabled', 'select', ['name' => 'enabled', 'label' => __('Enabled'), 'title' => __('Enabled'), 'values' => $this->booleanOptions->toOptionArray()]);
     $fieldset->addField('url_key', 'text', ['name' => 'url_key', 'label' => __('URL Key'), 'title' => __('URL Key')]);
     $fieldset->addField('meta_title', 'text', ['name' => 'meta_title', 'label' => __('Meta Title'), 'title' => __('Meta Title')]);
     $fieldset->addField('meta_description', 'textarea', ['name' => 'meta_description', 'label' => __('Meta Description'), 'title' => __('Meta Description')]);
     $fieldset->addField('meta_keywords', 'textarea', ['name' => 'meta_keywords', 'label' => __('Meta Keywords'), 'title' => __('Meta Keywords')]);
     $fieldset->addField('meta_robots', 'select', ['name' => 'meta_robots', 'label' => __('Meta Robots'), 'title' => __('Meta Robots'), 'values' => array_merge(['' => ''], $this->metaRobotsOptions->toOptionArray())]);
     $topicData = $this->_session->getData('mageplaza_blog_topic_data', true);
     if ($topicData) {
         $topic->addData($topicData);
     } else {
         if (!$topic->getId()) {
             $topic->addData($topic->getDefaultValues());
         }
     }
     $form->addValues($topic->getData());
     $this->setForm($form);
     return parent::_prepareForm();
 }
Пример #3
0
 /**
  * {@inheritdoc}
  * @return $this
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 protected function _prepareForm()
 {
     /** @var Attribute $attributeObject */
     $attributeObject = $this->_coreRegistry->registry('entity_attribute');
     /** @var \Magento\Framework\Data\Form $form */
     $form = $this->_formFactory->create(['data' => ['id' => 'edit_form', 'action' => $this->getData('action'), 'method' => 'post']]);
     $yesnoSource = $this->_yesNo->toOptionArray();
     $fieldset = $form->addFieldset('front_fieldset', ['legend' => __('Storefront Properties'), 'collapsable' => $this->getRequest()->has('popup')]);
     $fieldset->addField('is_searchable', 'select', ['name' => 'is_searchable', 'label' => __('Use in Search'), 'title' => __('Use in Search'), 'values' => $yesnoSource]);
     $fieldset->addField('is_visible_in_advanced_search', 'select', ['name' => 'is_visible_in_advanced_search', 'label' => __('Visible in Advanced Search'), 'title' => __('Visible in Advanced Search'), 'values' => $yesnoSource]);
     $fieldset->addField('is_comparable', 'select', ['name' => 'is_comparable', 'label' => __('Comparable on Storefront'), 'title' => __('Comparable on Storefront'), 'values' => $yesnoSource]);
     $this->_eventManager->dispatch('product_attribute_form_build_front_tab', ['form' => $form]);
     $fieldset->addField('is_used_for_promo_rules', 'select', ['name' => 'is_used_for_promo_rules', 'label' => __('Use for Promo Rule Conditions'), 'title' => __('Use for Promo Rule Conditions'), 'values' => $yesnoSource]);
     $fieldset->addField('is_wysiwyg_enabled', 'select', ['name' => 'is_wysiwyg_enabled', 'label' => __('Enable WYSIWYG'), 'title' => __('Enable WYSIWYG'), 'values' => $yesnoSource]);
     $fieldset->addField('is_html_allowed_on_front', 'select', ['name' => 'is_html_allowed_on_front', 'label' => __('Allow HTML Tags on Storefront'), 'title' => __('Allow HTML Tags on Storefront'), 'values' => $yesnoSource]);
     if (!$attributeObject->getId() || $attributeObject->getIsWysiwygEnabled()) {
         $attributeObject->setIsHtmlAllowedOnFront(1);
     }
     $fieldset->addField('is_visible_on_front', 'select', ['name' => 'is_visible_on_front', 'label' => __('Visible on Catalog Pages on Storefront'), 'title' => __('Visible on Catalog Pages on Storefront'), 'values' => $yesnoSource]);
     $fieldset->addField('used_in_product_listing', 'select', ['name' => 'used_in_product_listing', 'label' => __('Used in Product Listing'), 'title' => __('Used in Product Listing'), 'note' => __('Depends on design theme.'), 'values' => $yesnoSource]);
     $fieldset->addField('used_for_sort_by', 'select', ['name' => 'used_for_sort_by', 'label' => __('Used for Sorting in Product Listing'), 'title' => __('Used for Sorting in Product Listing'), 'note' => __('Depends on design theme.'), 'values' => $yesnoSource]);
     $this->_eventManager->dispatch('adminhtml_catalog_product_attribute_edit_frontend_prepare_form', ['form' => $form, 'attribute' => $attributeObject]);
     // define field dependencies
     $this->setChild('form_after', $this->getLayout()->createBlock('Magento\\Backend\\Block\\Widget\\Form\\Element\\Dependence')->addFieldMap("is_wysiwyg_enabled", 'wysiwyg_enabled')->addFieldMap("is_html_allowed_on_front", 'html_allowed_on_front')->addFieldMap("frontend_input", 'frontend_input_type')->addFieldDependence('wysiwyg_enabled', 'frontend_input_type', 'textarea')->addFieldDependence('html_allowed_on_front', 'wysiwyg_enabled', '0')->addFieldMap("is_searchable", 'searchable')->addFieldMap("is_visible_in_advanced_search", 'advanced_search')->addFieldDependence('advanced_search', 'searchable', '1'));
     $this->setForm($form);
     $form->setValues($attributeObject->getData());
     $this->propertyLocker->lock($form);
     return parent::_prepareForm();
 }
Пример #4
0
 public function testToHtml()
 {
     $fieldSet = $this->getMock('Magento\\Framework\\Data\\Form\\Element\\Fieldset', [], [], '', false);
     $form = $this->getMock('Magento\\Framework\\Data\\Form', [], [], '', false);
     $attributeModel = $this->getMock('\\Magento\\Catalog\\Model\\ResourceModel\\Eav\\Attribute', [], [], '', false);
     $entityType = $this->getMock('Magento\\Eav\\Model\\Entity\\Type', [], [], '', false);
     $formElement = $this->getMock('Magento\\Framework\\Data\\Form\\Element\\Text', ['setDisabled'], [], '', false);
     $directoryReadInterface = $this->getMock('\\Magento\\Framework\\Filesystem\\Directory\\ReadInterface');
     $this->registry->expects($this->any())->method('registry')->with('entity_attribute')->willReturn($attributeModel);
     $this->formFactory->expects($this->any())->method('create')->willReturn($form);
     $form->expects($this->any())->method('addFieldset')->willReturn($fieldSet);
     $form->expects($this->any())->method('getElement')->willReturn($formElement);
     $fieldSet->expects($this->any())->method('addField')->willReturnSelf();
     $attributeModel->expects($this->any())->method('getDefaultValue')->willReturn('default_value');
     $attributeModel->expects($this->any())->method('setDisabled')->willReturnSelf();
     $attributeModel->expects($this->any())->method('getId')->willReturn(1);
     $attributeModel->expects($this->any())->method('getEntityType')->willReturn($entityType);
     $attributeModel->expects($this->any())->method('getIsUserDefined')->willReturn(false);
     $attributeModel->expects($this->any())->method('getAttributeCode')->willReturn('attribute_code');
     $this->localeDate->expects($this->any())->method('getDateFormat')->willReturn('mm/dd/yy');
     $entityType->expects($this->any())->method('getEntityTypeCode')->willReturn('entity_type_code');
     $this->eavData->expects($this->any())->method('getFrontendClasses')->willReturn([]);
     $formElement->expects($this->exactly(3))->method('setDisabled')->willReturnSelf();
     $this->yesNo->expects($this->any())->method('toOptionArray')->willReturn(['yes', 'no']);
     $this->filesystem->expects($this->any())->method('getDirectoryRead')->willReturn($directoryReadInterface);
     $directoryReadInterface->expects($this->any())->method('getRelativePath')->willReturn('relative_path');
     $this->block->setData(['action' => 'save']);
     $this->block->toHtml();
 }
Пример #5
0
 /**
  * Adds 'used_in_recommender' form field
  * @param \Magento\Framework\Event\Observer $observer
  * @return void
  */
 public function addUsedInRecommender(\Magento\Framework\Event\Observer $observer)
 {
     /** @var \Magento\Framework\Data\Form $form */
     $form = $observer->getEvent()->getForm();
     $fieldset = $form->getElement('advanced_fieldset');
     $fieldset->addField('used_in_recommender', 'select', ['name' => 'used_in_recommender', 'label' => __('Used in Recommender'), 'title' => __('Used in Recommender (Exported to the recommender system)'), 'note' => __('Exported to the recommender system'), 'values' => $this->_yesNo->toOptionArray()]);
 }
 /**
  * @dataProvider dataAddFields
  */
 public function testAddFields($expected)
 {
     $this->moduleManagerMock->expects($this->once())->method('isOutputEnabled')->willReturn($expected['isOutputEnabled']);
     $this->eventObserverMock->expects($this->exactly($expected['methods_count']))->method('getForm')->willReturn($this->formMock);
     $element = $this->getMock('Magento\\Framework\\Data\\Form\\Element\\AbstractElement', [], [], '', false);
     $this->formMock->expects($this->exactly($expected['methods_count']))->method('getElement')->with('base_fieldset')->willReturn($element);
     $element->expects($this->exactly($expected['addField_count']))->method('addField');
     $this->yesNoMock->expects($this->exactly($expected['yesno_count']))->method('toOptionArray');
     $this->observerMock->execute($this->eventObserverMock);
 }
 /**
  * @param \Magento\Framework\Event\Observer $observer
  * @return void
  */
 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     if (!$this->moduleManager->isOutputEnabled('Magento_LayeredNavigation')) {
         return;
     }
     /** @var \Magento\Framework\Data\Form\AbstractForm $form */
     $form = $observer->getForm();
     $fieldset = $form->getElement('front_fieldset');
     $fieldset->addField('is_filterable', 'select', ['name' => 'is_filterable', 'label' => __("Use in Layered Navigation"), 'title' => __('Can be used only with catalog input type Dropdown, Multiple Select and Price'), 'note' => __('Can be used only with catalog input type Dropdown, Multiple Select and Price.'), 'values' => [['value' => '0', 'label' => __('No')], ['value' => '1', 'label' => __('Filterable (with results)')], ['value' => '2', 'label' => __('Filterable (no results)')]]]);
     $fieldset->addField('is_filterable_in_search', 'select', ['name' => 'is_filterable_in_search', 'label' => __("Use in Search Results Layered Navigation"), 'title' => __('Can be used only with catalog input type Dropdown, Multiple Select and Price'), 'note' => __('Can be used only with catalog input type Dropdown, Multiple Select and Price.'), 'values' => $this->optionList->toOptionArray()]);
     $fieldset->addField('position', 'text', ['name' => 'position', 'label' => __('Position'), 'title' => __('Position in Layered Navigation'), 'note' => __('Position of attribute in layered navigation block.'), 'class' => 'validate-digits']);
 }
 /**
  * @param \Magento\Framework\Event\Observer $observer
  * @return void
  */
 public function execute(EventObserver $observer)
 {
     if (!$this->moduleManager->isOutputEnabled('Magento_Swatches')) {
         return;
     }
     /** @var \Magento\Framework\Data\Form $form */
     $form = $observer->getForm();
     $fieldset = $form->getElement('base_fieldset');
     $yesnoSource = $this->yesNo->toOptionArray();
     $fieldset->addField('update_product_preview_image', 'select', ['name' => 'update_product_preview_image', 'label' => __('Update Product Preview Image'), 'title' => __('Update Product Preview Image'), 'note' => __('Filtering by this attribute will update the product image on catalog page'), 'values' => $yesnoSource], 'is_filterable');
     $fieldset->addField('use_product_image_for_swatch', 'select', ['name' => 'use_product_image_for_swatch', 'label' => __('Use Product Image for Swatch if Possible'), 'title' => __('Use Product Image for Swatch if Possible'), 'note' => __('Allows use fallback logic for replacing swatch image with product swatch or base image'), 'values' => $yesnoSource], 'is_filterable');
 }
Пример #9
0
 /**
  * Prepare form before rendering HTML
  *
  * @return $this
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 protected function _prepareForm()
 {
     $model = $this->_coreRegistry->registry('current_promo_quote_rule');
     /** @var \Magento\Framework\Data\Form $form */
     $form = $this->_formFactory->create();
     $form->setHtmlIdPrefix('rule_');
     $fieldset = $form->addFieldset('action_fieldset', ['legend' => __('Pricing Structure Rules')]);
     $fieldset->addField('simple_action', 'select', ['label' => __('Apply'), 'name' => 'simple_action', 'options' => [\Magento\SalesRule\Model\Rule::BY_PERCENT_ACTION => __('Percent of product price discount'), \Magento\SalesRule\Model\Rule::BY_FIXED_ACTION => __('Fixed amount discount'), \Magento\SalesRule\Model\Rule::CART_FIXED_ACTION => __('Fixed amount discount for whole cart'), \Magento\SalesRule\Model\Rule::BUY_X_GET_Y_ACTION => __('Buy X get Y free (discount amount is Y)')]]);
     $fieldset->addField('discount_amount', 'text', ['name' => 'discount_amount', 'required' => true, 'class' => 'validate-not-negative-number', 'label' => __('Discount Amount')]);
     $model->setDiscountAmount($model->getDiscountAmount() * 1);
     $fieldset->addField('discount_qty', 'text', ['name' => 'discount_qty', 'label' => __('Maximum Qty Discount is Applied To')]);
     $model->setDiscountQty($model->getDiscountQty() * 1);
     $fieldset->addField('discount_step', 'text', ['name' => 'discount_step', 'label' => __('Discount Qty Step (Buy X)')]);
     $fieldset->addField('apply_to_shipping', 'select', ['label' => __('Apply to Shipping Amount'), 'title' => __('Apply to Shipping Amount'), 'name' => 'apply_to_shipping', 'values' => $this->_sourceYesno->toOptionArray()]);
     $fieldset->addField('stop_rules_processing', 'select', ['label' => __('Discard subsequent rules'), 'title' => __('Discard subsequent rules'), 'name' => 'stop_rules_processing', 'options' => ['1' => __('Yes'), '0' => __('No')]]);
     $renderer = $this->_rendererFieldset->setTemplate('Magento_CatalogRule::promo/fieldset.phtml')->setNewChildUrl($this->getUrl('sales_rule/promo_quote/newActionHtml/form/rule_actions_fieldset'));
     $fieldset = $form->addFieldset('actions_fieldset', ['legend' => __('Apply the rule only to cart items matching the following conditions ' . '(leave blank for all items).')])->setRenderer($renderer);
     $fieldset->addField('actions', 'text', ['name' => 'actions', 'label' => __('Apply To'), 'title' => __('Apply To'), 'required' => true])->setRule($model)->setRenderer($this->_ruleActions);
     $this->_eventManager->dispatch('adminhtml_block_salesrule_actions_prepareform', ['form' => $form]);
     $form->setValues($model->getData());
     if ($model->isReadonly()) {
         foreach ($fieldset->getElements() as $element) {
             $element->setReadonly(true, true);
         }
     }
     $this->setForm($form);
     return parent::_prepareForm();
 }
Пример #10
0
 /**
  * Prepare form
  *
  * @return $this
  */
 protected function _prepareForm()
 {
     /**
      * Checking if user have permission to save information
      */
     if ($this->_isAllowedAction('Ves_Setup::import')) {
         $isElementDisabled = false;
     } else {
         $isElementDisabled = true;
     }
     /** @var \Magento\Framework\Data\Form $form */
     $form = $this->_formFactory->create(['data' => ['id' => 'edit_form', 'action' => $this->getData('action'), 'method' => 'post', 'enctype' => 'multipart/form-data']]);
     $fieldset = $form->addFieldset('base_fieldset', ['legend' => __('Ves Setup Import')]);
     $folders = $this->_exportFolders->toArray();
     $fds = [];
     foreach ($folders as $k => $v) {
         $k = strtolower(str_replace("/", "-", $k));
         $fds[$k] = $v;
     }
     $fieldset->addField('folder', 'select', ['label' => __('Folder'), 'title' => __('Folder'), 'name' => 'folder', 'options' => $fds, 'disabled' => $isElementDisabled, 'class' => 'ves-import']);
     foreach ($this->_exportFolders->toArray() as $key => $val) {
         $orginKey = $key;
         $key = strtolower(str_replace("/", "-", $key));
         $fieldPreset = $fieldset->addField($key, 'select', ['name' => $key, 'label' => __('Select Configuration to Import'), 'title' => __('Select Configuration to Import'), 'values' => $this->_importFiles->toOptionArray($orginKey), 'note' => '
                 Folder: <strong>app/design/frontend/' . $orginKey . '/backup</strong>
                 <script type="text/javascript">
                 require(["jquery"], function(){
                     jQuery("#' . $key . '").parents(".admin__field").hide();
                     jQuery(".ves-import").change(function(){
                         var folder_name = jQuery(this).val();
                         if(folder_name!="' . $key . '"){
                             jQuery("#' . $key . '").parents(".admin__field").hide();    
                         }else{
                             jQuery("#' . $key . '").parents(".admin__field").show();    
                         }
                     }).change();
                     jQuery("#' . $key . '").change(function(){
                         var data_import_file = jQuery(this).val();
                         if(data_import_file == "data_import_file"){
                             jQuery("#data_import_file").parents(".admin__field").show();
                         }else{
                             jQuery("#data_import_file").parents(".admin__field").hide();
                         }
                     }).change();
                 });</script>']);
     }
     $fieldset->addField('data_import_file', 'file', ['name' => 'data_import_file', 'label' => __('Upload Custom File'), 'title' => __('Upload Custom File'), 'after_element_html' => '
             <script type="text/javascript">
                 require(["jquery"], function(){
                     jQuery("#data_import_file").parents(".admin__field").hide();
                 });
             </script>
             ']);
     $fieldset->addField('overwrite_blocks', 'select', ['name' => 'overwrite_blocks', 'label' => __('Overwrite Existing Blocks'), 'title' => __('Overwrite Existing Blocks'), 'values' => $this->_yesno->toArray(), 'note' => __('If set to <b>Yes</b>, the import data will override exist data. Check exits data according to the field <b>URL Key</b> of <b>Cms Pages</b> and the field <b>Identifier</b> of <b>Static Block</b>.<br><br>If set to <b>No</b>, the function import will empty data of all table of <b>CMS Page</b> and <b>Static Block</b>, then insert import data.')]);
     $field = $fieldset->addField('store_id', 'select', ['name' => 'store_id', 'label' => __('Configuration Scope'), 'title' => __('Configuration Scope'), 'values' => $this->_systemStore->getStoreValuesForForm(false, true), 'disabled' => $isElementDisabled, 'note' => __('Imported configuration settings will be applied to selected scope (selected store view or website). If you\'re not sure what is \'scope\' in Magento system configuration.<br/><br/>It is highly recommended to leave the default scope <strong>\'Default Config\'</strong>. In this case imported configuration will be applied to all existing store views.')]);
     $form->setUseContainer(true);
     $this->setForm($form);
     return parent::_prepareForm();
 }
Пример #11
0
 /**
  * @SuppressWarnings(PHPMD.CamelCaseMethodName)
  * @SuppressWarnings(PHPMD.ElseExpression)
  *
  * {@inheritDoc}
  */
 protected function _prepareValueOptions()
 {
     $selectReady = $this->getData('value_select_options');
     $hashedReady = $this->getData('value_option');
     if (in_array($this->getAttribute(), ['stock.is_in_stock', 'has_image', 'price.is_discount'])) {
         $selectOptions = $this->booleanSource->toOptionArray();
         $this->_setSelectOptions($selectOptions, $selectReady, $hashedReady);
     } else {
         parent::_prepareValueOptions();
     }
 }
Пример #12
0
 /**
  * Prepare form
  *
  * @return $this
  */
 protected function _prepareForm()
 {
     /** @var \Sample\News\Model\Author $author */
     $author = $this->_coreRegistry->registry('sample_news_author');
     $form = $this->_formFactory->create();
     $form->setHtmlIdPrefix('author_');
     $form->setFieldNameSuffix('author');
     $fieldset = $form->addFieldset('base_fieldset', ['legend' => __('Author Information'), 'class' => 'fieldset-wide']);
     $fieldset->addType('image', 'Sample\\News\\Block\\Adminhtml\\Author\\Helper\\Image');
     $fieldset->addType('file', 'Sample\\News\\Block\\Adminhtml\\Author\\Helper\\File');
     if ($author->getId()) {
         $fieldset->addField('author_id', 'hidden', ['name' => 'author_id']);
     }
     $fieldset->addField('name', 'text', ['name' => 'name', 'label' => __('Name'), 'title' => __('Name'), 'required' => true]);
     $fieldset->addField('url_key', 'text', ['name' => 'url_key', 'label' => __('URL Key'), 'title' => __('URL Key')]);
     if ($this->_storeManager->isSingleStoreMode()) {
         $fieldset->addField('store_id', 'hidden', ['name' => 'stores[]', 'value' => $this->_storeManager->getStore(true)->getId()]);
         $author->setStoreId($this->_storeManager->getStore(true)->getId());
     }
     $fieldset->addField('is_active', 'select', ['label' => __('Is Active'), 'title' => __('Is Active'), 'name' => 'is_active', 'required' => true, 'options' => $author->getAvailableStatuses()]);
     $fieldset->addField('in_rss', 'select', ['label' => __('Show in RSS'), 'title' => __('Show in RSS'), 'name' => 'in_rss', 'required' => true, 'options' => $this->booleanOptions->toArray()]);
     $fieldset->addField('biography', 'editor', ['name' => 'biography', 'label' => __('Biography'), 'title' => __('Biography'), 'style' => 'height:36em', 'required' => true, 'config' => $this->wysiwygConfig->getConfig()]);
     $fieldset->addField('dob', 'date', ['name' => 'dob', 'label' => __('Date of birth'), 'title' => __('Date of birth'), 'image' => $this->getViewFileUrl('images/grid-cal.png'), 'date_format' => $this->_localeDate->getDateFormat(\IntlDateFormatter::SHORT), 'class' => 'validate-date']);
     $fieldset->addField('type', 'select', ['label' => __('Type'), 'title' => __('Type'), 'name' => 'type', 'required' => true, 'options' => $this->typeOptions->getOptions()]);
     $fieldset->addField('awards', 'multiselect', ['name' => 'awards', 'label' => __('Awards'), 'title' => __('Awards'), 'values' => $this->awardOptions->toOptionArray()]);
     $fieldset->addField('avatar', 'image', ['name' => 'avatar', 'label' => __('Avatar'), 'title' => __('Avatar')]);
     $fieldset->addField('resume', 'file', ['name' => 'resume', 'label' => __('Resume'), 'title' => __('Resume')]);
     $fieldset->addField('country', 'select', ['name' => 'country', 'label' => __('Country'), 'title' => __('Country'), 'options' => $this->countryOptions->getOptions()]);
     $authorData = $this->_session->getData('sample_news_author_data', true);
     if ($authorData) {
         $author->addData($authorData);
     } else {
         if (!$author->getId()) {
             $author->addData($author->getDefaultValues());
         }
     }
     $form->addValues($author->getData());
     $this->setForm($form);
     return parent::_prepareForm();
 }
Пример #13
0
 /**
  * Init base fields :
  *  - thesaurus name
  *  - store id
  *
  * @param \Magento\Framework\Data\Form\Element\Fieldset     $fieldset The fieldset
  * @param \Smile\ElasticsuiteThesaurus\Model\Thesaurus|null $model    Current Thesaurus
  *
  * @throws \Magento\Framework\Exception\LocalizedException
  * @SuppressWarnings(PHPMD.ElseExpression)
  *
  * @return \Smile\ElasticsuiteThesaurus\Block\Adminhtml\Thesaurus\Edit\Form
  */
 private function initBaseFields($fieldset, $model)
 {
     $fieldset->addField('name', 'text', ['name' => 'name', 'label' => __('Thesaurus Name'), 'title' => __('Thesaurus Name'), 'required' => true]);
     $fieldset->addField('is_active', 'select', ['name' => 'is_active', 'label' => __('Active'), 'title' => __('Active'), 'values' => $this->booleanSource->toOptionArray()]);
     if (!$this->_storeManager->isSingleStoreMode()) {
         $field = $fieldset->addField('store_id', 'multiselect', ['name' => 'stores[]', 'label' => __('Store'), 'title' => __('Store'), 'values' => $this->systemStore->getStoreValuesForForm(false, true), 'required' => true]);
         $renderer = $this->getLayout()->createBlock('Magento\\Backend\\Block\\Store\\Switcher\\Form\\Renderer\\Fieldset\\Element');
         $field->setRenderer($renderer);
     } else {
         $fieldset->addField('store_id', 'hidden', ['name' => 'store_id']);
         $model->setStoreIds([$this->_storeManager->getStore(true)->getId()]);
     }
     return $this;
 }
Пример #14
0
 /**
  * Prepare form
  *
  * @return $this
  */
 protected function _prepareForm()
 {
     /** @var \Gemtoo\Blog\Model\Article $article */
     $article = $this->_coreRegistry->registry('gemtoo_blog_article');
     $form = $this->_formFactory->create();
     $form->setHtmlIdPrefix('article');
     $form->setFieldNameSuffix('article');
     $fieldset = $form->addFieldset('base_fieldset', ['legend' => __('Article Information'), 'class' => 'fieldset-wide']);
     $fieldset->addType('image', 'Gemtoo\\Blog\\Block\\Adminhtml\\Article\\Helper\\Image');
     $fieldset->addType('file', 'Gemtoo\\Blog\\Block\\Adminhtml\\Article\\Helper\\File');
     if ($article->getId()) {
         $fieldset->addField('article_id', 'hidden', ['name' => 'article_id']);
     }
     $fieldset->addField('name', 'text', ['name' => 'name', 'label' => __('Name'), 'title' => __('Name'), 'required' => true]);
     $fieldset->addField('url_key', 'text', ['name' => 'url_key', 'label' => __('URL Key'), 'title' => __('URL Key')]);
     if ($this->_storeManager->isSingleStoreMode()) {
         $fieldset->addField('store_id', 'hidden', ['name' => 'stores[]', 'value' => $this->_storeManager->getStore(true)->getId()]);
         $article->setStoreId($this->_storeManager->getStore(true)->getId());
     }
     $fieldset->addField('is_active', 'select', ['label' => __('Is Active'), 'title' => __('Is Active'), 'name' => 'is_active', 'required' => true, 'options' => $article->getAvailableStatuses()]);
     $fieldset->addField('in_rss', 'select', ['label' => __('Show in RSS'), 'title' => __('Show in RSS'), 'name' => 'in_rss', 'required' => true, 'options' => $this->booleanOptions->toArray()]);
     $fieldset->addField('content', 'editor', ['name' => 'content', 'label' => __('Content'), 'title' => __('Content'), 'style' => 'height:36em', 'required' => true, 'config' => $this->wysiwygConfig->getConfig()]);
     $fieldset->addField('dop', 'date', ['name' => 'dop', 'label' => __('Date of publication'), 'title' => __('Date of publication'), 'image' => $this->getViewFileUrl('images/grid-cal.png'), 'date_format' => $this->_localeDate->getDateFormat(\IntlDateFormatter::SHORT), 'class' => 'validate-date']);
     $fieldset->addField('image', 'image', ['name' => 'image', 'label' => __('Image'), 'title' => __('Image')]);
     $fieldset->addField('file', 'file', ['name' => 'file', 'label' => __('File'), 'title' => __('File')]);
     $articleData = $this->_session->getData('gemtoo_blog_article_data', true);
     if ($articleData) {
         $article->addData($articleData);
     } else {
         if (!$article->getId()) {
             $article->addData($article->getDefaultValues());
         }
     }
     $form->addValues($article->getData());
     $this->setForm($form);
     return parent::_prepareForm();
 }
Пример #15
0
 /**
  * Prepare form
  *
  * @return $this
  */
 protected function _prepareForm()
 {
     /** @var \Mageplaza\Blog\Model\Post $post */
     $post = $this->_coreRegistry->registry('mageplaza_blog_post');
     $form = $this->_formFactory->create();
     $form->setHtmlIdPrefix('post_');
     $form->setFieldNameSuffix('post');
     $fieldset = $form->addFieldset('base_fieldset', ['legend' => __('Post Information'), 'class' => 'fieldset-wide']);
     $fieldset->addType('image', 'Mageplaza\\Blog\\Block\\Adminhtml\\Post\\Helper\\Image');
     if ($post->getId()) {
         $fieldset->addField('post_id', 'hidden', ['name' => 'post_id']);
     }
     $fieldset->addField('name', 'text', ['name' => 'name', 'label' => __('Name'), 'title' => __('Name'), 'required' => true, 'note' => __('Post name')]);
     $fieldset->addField('short_description', 'textarea', ['name' => 'short_description', 'label' => __('Short Description'), 'title' => __('Short Description'), 'note' => __('Short Description')]);
     $fieldset->addField('post_content', 'editor', ['name' => 'post_content', 'label' => __('Content'), 'title' => __('Content'), 'note' => __('Post Content'), 'config' => $this->wysiwygConfig->getConfig()]);
     $fieldset->addField('image', 'image', ['name' => 'image', 'label' => __('Image'), 'title' => __('Image'), 'note' => __('Featured image')]);
     $fieldset->addField('enabled', 'select', ['name' => 'enabled', 'label' => __('Enabled'), 'title' => __('Enabled'), 'values' => $this->booleanOptions->toOptionArray()]);
     $fieldset->addField('url_key', 'text', ['name' => 'url_key', 'label' => __('URL Key'), 'title' => __('URL Key')]);
     $fieldset->addField('in_rss', 'select', ['name' => 'in_rss', 'label' => __('In RSS'), 'title' => __('In RSS'), 'values' => $this->booleanOptions->toOptionArray()]);
     $fieldset->addField('allow_comment', 'select', ['name' => 'allow_comment', 'label' => __('Allow Comment'), 'title' => __('Allow Comment'), 'values' => $this->booleanOptions->toOptionArray()]);
     $fieldset->addField('meta_title', 'text', ['name' => 'meta_title', 'label' => __('Meta Title'), 'title' => __('Meta Title')]);
     $fieldset->addField('meta_description', 'textarea', ['name' => 'meta_description', 'label' => __('Meta Description'), 'title' => __('Meta Description')]);
     $fieldset->addField('meta_keywords', 'textarea', ['name' => 'meta_keywords', 'label' => __('Meta Keywords'), 'title' => __('Meta Keywords')]);
     $fieldset->addField('meta_robots', 'select', ['name' => 'meta_robots', 'label' => __('Meta Robots'), 'title' => __('Meta Robots'), 'values' => array_merge(['' => ''], $this->metaRobotsOptions->toOptionArray())]);
     $postData = $this->_session->getData('mageplaza_blog_post_data', true);
     if ($postData) {
         $post->addData($postData);
     } else {
         if (!$post->getId()) {
             $post->addData($post->getDefaultValues());
         }
     }
     $form->addValues($post->getData());
     $this->setForm($form);
     return parent::_prepareForm();
 }
Пример #16
0
 /**
  * Prepare form
  *
  * @return $this
  */
 protected function _prepareForm()
 {
     /**
      * Checking if user have permission to save information
      */
     if ($this->_isAllowedAction('Ves_Setup::export')) {
         $isElementDisabled = false;
     } else {
         $isElementDisabled = true;
     }
     /** @var \Magento\Framework\Data\Form $form */
     $form = $this->_formFactory->create(['data' => ['id' => 'edit_form', 'action' => $this->getData('action'), 'method' => 'post', 'enctype' => 'multipart/form-data']]);
     $fieldset = $form->addFieldset('base_fieldset', ['legend' => __('Ves Setup Export')]);
     $fieldset->addField('file_name', 'text', ['name' => 'file_name', 'label' => __('File Name'), 'title' => __('File Name'), 'required' => true, 'disabled' => $isElementDisabled, 'note' => __('This will be the name of the file in which configuration will be saved. You can enter any name you want.')]);
     $fieldset->addField('file_extension', 'select', ['name' => 'file_extension', 'label' => __('File Extension'), 'title' => __('File Extension'), 'options' => $this->_fileExtension->toArray(), 'disabled' => $isElementDisabled]);
     $fieldset->addField('isdowload', 'select', ['label' => __('Download File'), 'title' => __('Download File'), 'name' => 'isdowload', 'options' => $this->_yesno->toArray(), 'disabled' => $isElementDisabled]);
     $fieldset->addField('folder', 'select', ['label' => __('Folder'), 'title' => __('Folder'), 'name' => 'folder', 'options' => $this->_exportFolders->toArray(), 'disabled' => $isElementDisabled, 'note' => '<script type="text/javascript">
                     require(["jquery"], function(){
                         jQuery("#folder").change(function(){
                             var val = jQuery(this).val();
                             jQuery("#folder-note").html("");
                             jQuery("#folder-note").append("Folder: "+val);
                         }).change();
                     });
                 </script>']);
     $field = $fieldset->addField('store_id', 'select', ['name' => 'store_id', 'label' => __('Configuration Scope'), 'title' => __('Configuration Scope'), 'values' => $this->_systemStore->getStoreValuesForForm(false, true), 'disabled' => $isElementDisabled, 'note' => __('Configuration of selected store will be saved in a file. Apply for all system config of modules')]);
     $field = $fieldset->addField('modules', 'multiselect', ['name' => 'modules[]', 'label' => __('Ves Modules'), 'title' => __('Ves Modules'), 'values' => $this->_vesModules->toOptionArray(), 'disabled' => $isElementDisabled]);
     $renderer = $this->getLayout()->createBlock('Ves\\Setup\\Block\\Adminhtml\\Form\\Renderer\\Fieldset\\Element');
     $field->setRenderer($renderer);
     $field = $fieldset->addField('cmspages', 'multiselect', ['name' => 'cmspages[]', 'label' => __('CMS Pages'), 'title' => __('CMS Pages'), 'values' => $this->_cmsPage->toOptionArray(), 'disabled' => $isElementDisabled]);
     $renderer = $this->getLayout()->createBlock('Ves\\Setup\\Block\\Adminhtml\\Form\\Renderer\\Fieldset\\Element');
     $field->setRenderer($renderer);
     $field = $fieldset->addField('cmsblocks', 'multiselect', ['name' => 'cmsblocks[]', 'label' => __('CMS Blocks'), 'title' => __('CMS Blocks'), 'values' => $this->_staticBlock->toOptionArray(), 'disabled' => $isElementDisabled]);
     $renderer = $this->getLayout()->createBlock('Ves\\Setup\\Block\\Adminhtml\\Form\\Renderer\\Fieldset\\Element');
     $field->setRenderer($renderer);
     $field = $fieldset->addField('widgets', 'multiselect', ['name' => 'widgets[]', 'label' => __('Widgets'), 'title' => __('Widgets'), 'values' => $this->_widgets->toOptionArray(), 'disabled' => $isElementDisabled]);
     $renderer = $this->getLayout()->createBlock('Ves\\Setup\\Block\\Adminhtml\\Form\\Renderer\\Fieldset\\Element');
     $field->setRenderer($renderer);
     $form->setUseContainer(true);
     $this->setForm($form);
     return parent::_prepareForm();
 }
Пример #17
0
 /**
  * Retrieve qty type select html
  *
  * @return string
  */
 public function getQtyTypeSelectHtml()
 {
     $select = $this->getLayout()->createBlock('Magento\\Framework\\View\\Element\\Html\\Select')->setData(['id' => $this->getFieldId() . '_<%- data.index %>_can_change_qty', 'class' => 'select'])->setName($this->getFieldName() . '[<%- data.parentIndex %>][<%- data.index %>][selection_can_change_qty]')->setOptions($this->_yesno->toOptionArray());
     return $select->getHtml();
 }
Пример #18
0
 /**
  * Retrieve Purchased Separately HTML select
  *
  * @return string
  */
 public function getPurchasedSeparatelySelect()
 {
     $select = $this->getLayout()->createBlock('Magento\\Framework\\View\\Element\\Html\\Select')->setName('product[links_purchased_separately]')->setId('downloadable_link_purchase_type')->setOptions($this->_sourceModel->toOptionArray())->setValue($this->getProduct()->getLinksPurchasedSeparately())->setClass('admin__control-select');
     return $select->getHtml();
 }
Пример #19
0
 /**
  * Append spellchecking related fields.
  *
  * @param Fieldset $fieldset Target fieldset
  *
  * @return FrontPlugin
  */
 private function addSearchFields(Fieldset $fieldset)
 {
     $fieldset->addField('search_weight', 'select', ['name' => 'search_weight', 'label' => __('Search Weight'), 'values' => $this->weightSource->getOptions()], 'is_searchable');
     $fieldset->addField('is_used_in_spellcheck', 'select', ['name' => 'is_used_in_spellcheck', 'label' => __('Used in spellcheck'), 'values' => $this->booleanSource->toOptionArray()], 'search_weight');
     return $this;
 }
Пример #20
0
 /**
  * @return mixed
  */
 public function getRequireSelectHtml()
 {
     $select = $this->getLayout()->createBlock('Magento\\Framework\\View\\Element\\Html\\Select')->setData(['id' => $this->getFieldId() . '_<%- data.id %>_is_require', 'class' => 'select'])->setName($this->getFieldName() . '[<%- data.id %>][is_require]')->setOptions($this->_configYesNo->toOptionArray());
     return $select->getHtml();
 }