本文整理汇总了PHP中Magento\Store\Model\System\Store类的典型用法代码示例。如果您正苦于以下问题:PHP Store类的具体用法?PHP Store怎么用?PHP Store使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Store类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _prepareForm
/**
* Prepare form
*
* @return $this
*/
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();
}
示例2: _prepareForm
/**
* Initialise form fields
*
* @return void
*/
protected function _prepareForm()
{
/** @var \Magento\Framework\Data\Form $form */
$form = $this->_formFactory->create();
$fieldset = $form->addFieldset('general', array('legend' => __('General Settings')));
if (!$this->_storeManager->isSingleStoreMode()) {
$field = $fieldset->addField('store_id', 'select', array('label' => __('Store'), 'title' => __('Store'), 'values' => $this->_systemStore->getStoreValuesForForm(), 'name' => 'store_id', 'required' => true));
$renderer = $this->getLayout()->createBlock('Magento\\Backend\\Block\\Store\\Switcher\\Form\\Renderer\\Fieldset\\Element');
$field->setRenderer($renderer);
} else {
$fieldset->addField('store_id', 'hidden', array('name' => 'store_id', 'value' => $this->_storeManager->getStore(true)->getId()));
}
/** @var $label \Magento\Framework\View\Design\Theme\Label */
$label = $this->_labelFactory->create();
$options = $label->getLabelsCollection(__('-- Please Select --'));
$fieldset->addField('design', 'select', array('label' => __('Custom Design'), 'title' => __('Custom Design'), 'values' => $options, 'name' => 'design', 'required' => true));
$dateFormat = $this->_localeDate->getDateFormat(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_SHORT);
$fieldset->addField('date_from', 'date', array('label' => __('Date From'), 'title' => __('Date From'), 'name' => 'date_from', 'image' => $this->getViewFileUrl('images/grid-cal.gif'), 'date_format' => $dateFormat));
$fieldset->addField('date_to', 'date', array('label' => __('Date To'), 'title' => __('Date To'), 'name' => 'date_to', 'image' => $this->getViewFileUrl('images/grid-cal.gif'), 'date_format' => $dateFormat));
$formData = $this->_backendSession->getDesignData(true);
if (!$formData) {
$formData = $this->_coreRegistry->registry('design')->getData();
} else {
$formData = $formData['design'];
}
$form->addValues($formData);
$form->setFieldNameSuffix('design');
$this->setForm($form);
}
示例3: _prepareForm
/**
* Prepare add review form
*
* @return void
*/
protected function _prepareForm()
{
/** @var \Magento\Framework\Data\Form $form */
$form = $this->_formFactory->create();
$fieldset = $form->addFieldset('add_review_form', array('legend' => __('Review Details')));
$fieldset->addField('product_name', 'note', array('label' => __('Product'), 'text' => 'product_name'));
$fieldset->addField('detailed_rating', 'note', array('label' => __('Product Rating'), 'required' => true, 'text' => '<div id="rating_detail">' . $this->getLayout()->createBlock('Magento\\Review\\Block\\Adminhtml\\Rating\\Detailed')->toHtml() . '</div>'));
$fieldset->addField('status_id', 'select', array('label' => __('Status'), 'required' => true, 'name' => 'status_id', 'values' => $this->_reviewData->getReviewStatusesOptionArray()));
/**
* Check is single store mode
*/
if (!$this->_storeManager->isSingleStoreMode()) {
$field = $fieldset->addField('select_stores', 'multiselect', array('label' => __('Visible In'), 'required' => true, 'name' => 'select_stores[]', 'values' => $this->_systemStore->getStoreValuesForForm()));
$renderer = $this->getLayout()->createBlock('Magento\\Backend\\Block\\Store\\Switcher\\Form\\Renderer\\Fieldset\\Element');
$field->setRenderer($renderer);
}
$fieldset->addField('nickname', 'text', array('name' => 'nickname', 'title' => __('Nickname'), 'label' => __('Nickname'), 'maxlength' => '50', 'required' => true));
$fieldset->addField('title', 'text', array('name' => 'title', 'title' => __('Summary of Review'), 'label' => __('Summary of Review'), 'maxlength' => '255', 'required' => true));
$fieldset->addField('detail', 'textarea', array('name' => 'detail', 'title' => __('Review'), 'label' => __('Review'), 'style' => 'height: 600px;', 'required' => true));
$fieldset->addField('product_id', 'hidden', array('name' => 'product_id'));
/*$gridFieldset = $form->addFieldset('add_review_grid', array('legend' => __('Please select a product')));
$gridFieldset->addField('products_grid', 'note', array(
'text' => $this->getLayout()->createBlock('Magento\Review\Block\Adminhtml\Product\Grid')->toHtml(),
));*/
$form->setMethod('post');
$form->setUseContainer(true);
$form->setId('edit_form');
$form->setAction($this->getUrl('review/product/post'));
$this->setForm($form);
}
示例4: _prepareForm
/**
* Prepare form
*
* @return $this
*/
protected function _prepareForm()
{
/** @var $model \Magento\Cms\Model\Page */
$model = $this->_coreRegistry->registry('team');
/** @var \Magento\Framework\Data\Form $form */
$form = $this->_formFactory->create();
$form->setHtmlIdPrefix('page_');
$fieldset = $form->addFieldset('base_fieldset', ['legend' => __('Team Content')]);
$fieldset->addField('slogan', 'text', ['name' => 'slogan', 'label' => __('Team Slogan'), 'title' => __('Team Slogan'), 'required' => true]);
$fieldset->addField('team_color', 'text', ['name' => 'team_color', 'label' => __('Team Color'), 'title' => __('Team Color'), 'class' => 'jscolor {refine:false}']);
/**
* 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());
}
$form->setValues($model->getData());
$this->setForm($form);
return parent::_prepareForm();
}
示例5: _prepareForm
/**
* @return $this
*/
protected function _prepareForm()
{
$model = $this->_coreRegistry->registry('checkout_agreement');
/** @var \Magento\Framework\Data\Form $form */
$form = $this->_formFactory->create(array('data' => array('id' => 'edit_form', 'action' => $this->getData('action'), 'method' => 'post')));
$fieldset = $form->addFieldset('base_fieldset', array('legend' => __('Terms and Conditions Information'), 'class' => 'fieldset-wide'));
if ($model->getId()) {
$fieldset->addField('agreement_id', 'hidden', array('name' => 'agreement_id'));
}
$fieldset->addField('name', 'text', array('name' => 'name', 'label' => __('Condition Name'), 'title' => __('Condition Name'), 'required' => true));
$fieldset->addField('is_active', 'select', array('label' => __('Status'), 'title' => __('Status'), 'name' => 'is_active', 'required' => true, 'options' => array('1' => __('Enabled'), '0' => __('Disabled'))));
$fieldset->addField('is_html', 'select', array('label' => __('Show Content as'), 'title' => __('Show Content as'), 'name' => 'is_html', 'required' => true, 'options' => array(0 => __('Text'), 1 => __('HTML'))));
if (!$this->_storeManager->isSingleStoreMode()) {
$field = $fieldset->addField('store_id', 'multiselect', array('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', array('name' => 'stores[]', 'value' => $this->_storeManager->getStore(true)->getId()));
$model->setStoreId($this->_storeManager->getStore(true)->getId());
}
$fieldset->addField('checkbox_text', 'editor', array('name' => 'checkbox_text', 'label' => __('Checkbox Text'), 'title' => __('Checkbox Text'), 'rows' => '5', 'cols' => '30', 'wysiwyg' => false, 'required' => true));
$fieldset->addField('content', 'editor', array('name' => 'content', 'label' => __('Content'), 'title' => __('Content'), 'style' => 'height:24em;', 'wysiwyg' => false, 'required' => true));
$fieldset->addField('content_height', 'text', array('name' => 'content_height', 'label' => __('Content Height (css)'), 'title' => __('Content Height'), 'maxlength' => 25, 'class' => 'validate-css-length'));
$form->setValues($model->getData());
$form->setUseContainer(true);
$this->setForm($form);
return parent::_prepareForm();
}
示例6: generateCurrentOptions
/**
* Generate current options
*
* @return void
*/
protected function generateCurrentOptions()
{
$websiteCollection = $this->systemStore->getWebsiteCollection();
$groupCollection = $this->systemStore->getGroupCollection();
$storeCollection = $this->systemStore->getStoreCollection();
/** @var \Magento\Store\Model\Website $website */
foreach ($websiteCollection as $website) {
$groups = [];
/** @var \Magento\Store\Model\Group $group */
foreach ($groupCollection as $group) {
if ($group->getWebsiteId() == $website->getId()) {
$stores = [];
/** @var \Magento\Store\Model\Store $store */
foreach ($storeCollection as $store) {
if ($store->getGroupId() == $group->getId()) {
$name = $this->escaper->escapeHtml($store->getName());
$stores[$name]['label'] = str_repeat(' ', 8) . $name;
$stores[$name]['value'] = $store->getId();
}
}
if (!empty($stores)) {
$name = $this->escaper->escapeHtml($group->getName());
$groups[$name]['label'] = str_repeat(' ', 4) . $name;
$groups[$name]['value'] = array_values($stores);
}
}
}
if (!empty($groups)) {
$name = $this->escaper->escapeHtml($website->getName());
$this->currentOptions[$name]['label'] = $name;
$this->currentOptions[$name]['value'] = array_values($groups);
}
}
}
示例7: _prepareForm
/**
* @return $this
*
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function _prepareForm()
{
$model = $this->_coreRegistry->registry('current_ddg_rule');
$form = $this->_formFactory->create();
$form->setHtmlIdPrefix('rule_');
$fieldset = $form->addFieldset('base_fieldset', ['legend' => __('Rule Information')]);
if ($model->getId()) {
$fieldset->addField('id', 'hidden', ['name' => 'id']);
}
$fieldset->addField('name', 'text', ['name' => 'name', 'label' => __('Rule Name'), 'title' => __('Rule Name'), 'required' => true]);
$fieldset->addField('type', 'select', ['label' => __('Rule Type'), 'title' => __('Rule Type'), 'name' => 'type', 'required' => true, 'options' => [\Dotdigitalgroup\Email\Model\Rules::ABANDONED => 'Abandoned Cart Exclusion Rule', \Dotdigitalgroup\Email\Model\Rules::REVIEW => 'Review Email Exclusion Rule']]);
$fieldset->addField('status', 'select', ['label' => __('Status'), 'title' => __('Status'), 'name' => 'status', 'required' => true, 'options' => ['1' => __('Active'), '0' => __('Inactive')]]);
if (!$model->getId()) {
$model->setData('status', '0');
}
if ($this->_storeManager->isSingleStoreMode()) {
$websiteId = $this->_storeManager->getStore(true)->getWebsiteId();
$fieldset->addField('website_ids', 'hidden', ['name' => 'website_ids[]', 'value' => $websiteId]);
$model->setWebsiteIds($websiteId);
} else {
$field = $fieldset->addField('website_ids', 'multiselect', ['name' => 'website_ids[]', 'label' => __('Websites'), 'title' => __('Websites'), 'required' => true, 'values' => $this->systemStore->getWebsiteValuesForForm()]);
$renderer = $this->getLayout()->createBlock('Magento\\Backend\\Block\\Store\\Switcher\\Form\\Renderer\\Fieldset\\Element');
$field->setRenderer($renderer);
}
$form->setValues($model->getData());
$this->setForm($form);
return parent::_prepareForm();
}
示例8: _processWebsite
/**
* Process website info
*
* @param \Magento\Store\Model\System\Store $storeModel
* @param \Magento\Store\Model\Website $website
* @param string $section
* @param string $curStore
* @param string $curWebsite
* @param array $options
* @return array
*/
protected function _processWebsite(\Magento\Store\Model\System\Store $storeModel, \Magento\Store\Model\Website $website, $section, $curStore, $curWebsite, array $options)
{
$websiteShow = false;
foreach ($storeModel->getGroupCollection() as $group) {
if ($group->getWebsiteId() != $website->getId()) {
continue;
}
$groupShow = false;
foreach ($storeModel->getStoreCollection() as $store) {
if ($store->getGroupId() != $group->getId()) {
continue;
}
if (!$websiteShow) {
$websiteShow = true;
$options['website_' . $website->getCode()] = array('label' => $website->getName(), 'url' => $this->getUrl('*/*/*', array('section' => $section, 'website' => $website->getCode())), 'selected' => !$curStore && $curWebsite == $website->getCode(), 'style' => 'padding-left:16px; background:#DDD; font-weight:bold;');
}
if (!$groupShow) {
$groupShow = true;
$options['group_' . $group->getId() . '_open'] = array('is_group' => true, 'is_close' => false, 'label' => $group->getName(), 'style' => 'padding-left:32px;');
}
$options['store_' . $store->getCode()] = array('label' => $store->getName(), 'url' => $this->getUrl('*/*/*', array('section' => $section, 'website' => $website->getCode(), 'store' => $store->getCode())), 'selected' => $curStore == $store->getCode(), 'style' => '');
}
if ($groupShow) {
$options['group_' . $group->getId() . '_close'] = array('is_group' => true, 'is_close' => true);
}
}
return $options;
}
示例9: _prepareForm
/**
* Prepare form fields
*
* @return $this
*/
protected function _prepareForm()
{
$model = $this->_coreRegistry->registry('current_catalog_search');
/* @var $model \Magento\CatalogSearch\Model\Query */
/** @var \Magento\Framework\Data\Form $form */
$form = $this->_formFactory->create(array('data' => array('id' => 'edit_form', 'action' => $this->getData('action'), 'method' => 'post')));
$fieldset = $form->addFieldset('base_fieldset', array('legend' => __('General Information')));
$yesno = array(array('value' => 0, 'label' => __('No')), array('value' => 1, 'label' => __('Yes')));
if ($model->getId()) {
$fieldset->addField('query_id', 'hidden', array('name' => 'query_id'));
}
$fieldset->addField('query_text', 'text', array('name' => 'query_text', 'label' => __('Search Query'), 'title' => __('Search Query'), 'required' => true));
if (!$this->_storeManager->isSingleStoreMode()) {
$field = $fieldset->addField('store_id', 'select', array('name' => 'store_id', 'label' => __('Store'), 'title' => __('Store'), 'values' => $this->_systemStore->getStoreValuesForForm(true, false), 'required' => true));
$renderer = $this->getLayout()->createBlock('Magento\\Backend\\Block\\Store\\Switcher\\Form\\Renderer\\Fieldset\\Element');
$field->setRenderer($renderer);
} else {
$fieldset->addField('store_id', 'hidden', array('name' => 'store_id'));
$model->setStoreId($this->_storeManager->getStore(true)->getId());
}
if ($model->getId()) {
$fieldset->addField('num_results', 'text', array('name' => 'num_results', 'label' => __('Number of results'), 'title' => __('Number of results (For the last time placed)'), 'note' => __('For the last time placed.'), 'required' => true));
$fieldset->addField('popularity', 'text', array('name' => 'popularity', 'label' => __('Number of Uses'), 'title' => __('Number of Uses'), 'required' => true));
}
$fieldset->addField('synonym_for', 'text', array('name' => 'synonym_for', 'label' => __('Synonym For'), 'title' => __('Synonym For'), 'note' => __('Will make search for the query above return results for this search')));
$fieldset->addField('redirect', 'text', array('name' => 'redirect', 'label' => __('Redirect URL'), 'title' => __('Redirect URL'), 'class' => 'validate-url', 'note' => __('ex. http://domain.com')));
$fieldset->addField('display_in_terms', 'select', array('name' => 'display_in_terms', 'label' => __('Display in Suggested Terms'), 'title' => __('Display in Suggested Terms'), 'values' => $yesno));
$form->setValues($model->getData());
$form->setUseContainer(true);
$this->setForm($form);
return parent::_prepareForm();
}
示例10: prepareItem
/**
* Get data
*
* @param array $item
* @return string
*/
protected function prepareItem(array $item)
{
$content = '';
$origStores = $item['store_id'];
if (empty($origStores)) {
return '';
}
if (!is_array($origStores)) {
$origStores = [$origStores];
}
if (in_array(0, $origStores) && count($origStores) == 1) {
return __('All Store Views');
}
$data = $this->systemStore->getStoresStructure(false, $origStores);
foreach ($data as $website) {
$content .= $website['label'] . "<br/>";
foreach ($website['children'] as $group) {
$content .= str_repeat(' ', 3) . $this->escaper->escapeHtml($group['label']) . "<br/>";
foreach ($group['children'] as $store) {
$content .= str_repeat(' ', 6) . $this->escaper->escapeHtml($store['label']) . "<br/>";
}
}
}
return $content;
}
示例11: testPrepareDataSource
public function testPrepareDataSource()
{
$dataSource = ['data' => ['items' => [['stores' => [1]]]]];
$expectedVisibility = "Test Website<br/> Test group<br/> Test store<br/>";
$expectedDataSource = ['data' => ['items' => [['stores' => [1], 'visibility' => $expectedVisibility]]]];
$this->storeMock->expects($this->once())->method('getStoresStructure')->willReturn([['label' => 'Test Website', 'children' => [['label' => 'Test group', 'children' => [['label' => 'Test store']]]]]]);
$this->assertEquals($expectedDataSource, $this->getModel()->prepareDataSource($dataSource));
}
示例12: aroundSetForm
/**
* @param FrontTab $subject
* @param callable $proceed
* @param Form $form
* @return Front
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function aroundSetForm(FrontTab $subject, \Closure $proceed, Form $form)
{
$block = $proceed($form);
/** @var Fieldset $fieldset */
$fieldset = $form->getElement('front_fieldset');
$fieldset->addField('advanced_search_store_ids', 'multiselect', ['name' => 'advanced_search_store_ids[]', 'label' => __('Advanced Search Store(s)'), 'title' => __('Advanced Search Store(s)'), 'value' => 0, 'values' => $this->_systemStore->getStoreValuesForForm(false, true)], 'is_visible_in_advanced_search');
$subject->getChildBlock('form_after')->addFieldMap('advanced_search_store_ids', 'advanced_search_store_ids')->addFieldDependence('advanced_search_store_ids', 'advanced_search', '1')->addFieldDependence('advanced_search_store_ids', 'searchable', '1');
return $block;
}
示例13: testPrepareDataSource
/**
* @dataProvider prepareDataSourceDataProvider
*/
public function testPrepareDataSource($dataSource, $expectedResult)
{
$website = 'website';
$group = 'group';
$store = 'store';
$storeStructure = [1 => ['value' => 1, 'label' => $website, 'children' => [1 => ['value' => 1, 'label' => $group, 'children' => [1 => ['value' => 1, 'label' => $store]]]]]];
$this->escaperMock->expects($this->any())->method('escapeHtml')->willReturnMap([[$group, null, $group], [$store, null, $store]]);
$this->systemStoreMock->expects($this->any())->method('getStoresStructure')->willReturn($storeStructure);
$this->assertEquals($this->model->prepareDataSource($dataSource), $expectedResult);
}
示例14: getMetadataValues
/**
* Get metadata for sales rule form. It will be merged with form UI component declaration.
*
* @param Rule $rule
* @return array
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function getMetadataValues(\Magento\SalesRule\Model\Rule $rule)
{
$customerGroups = $this->groupRepository->getList($this->searchCriteriaBuilder->create())->getItems();
$applyOptions = [['label' => __('Percent of product price discount'), 'value' => Rule::BY_PERCENT_ACTION], ['label' => __('Fixed amount discount'), 'value' => Rule::BY_FIXED_ACTION], ['label' => __('Fixed amount discount for whole cart'), 'value' => Rule::CART_FIXED_ACTION], ['label' => __('Buy X get Y free (discount amount is Y)'), 'value' => Rule::BUY_X_GET_Y_ACTION]];
$couponTypesOptions = [];
$couponTypes = $this->salesRuleFactory->create()->getCouponTypes();
foreach ($couponTypes as $key => $couponType) {
$couponTypesOptions[] = ['label' => $couponType, 'value' => $key];
}
$labels = $rule->getStoreLabels();
return ['rule_information' => ['children' => ['website_ids' => ['arguments' => ['data' => ['config' => ['options' => $this->store->getWebsiteValuesForForm()]]]], 'is_active' => ['arguments' => ['data' => ['config' => ['options' => [['label' => __('Active'), 'value' => '1'], ['label' => __('Inactive'), 'value' => '0']]]]]], 'customer_group_ids' => ['arguments' => ['data' => ['config' => ['options' => $this->objectConverter->toOptionArray($customerGroups, 'id', 'code')]]]], 'coupon_type' => ['arguments' => ['data' => ['config' => ['options' => $couponTypesOptions]]]], 'is_rss' => ['arguments' => ['data' => ['config' => ['options' => [['label' => __('Yes'), 'value' => '1'], ['label' => __('No'), 'value' => '0']]]]]]]], 'actions' => ['children' => ['simple_action' => ['arguments' => ['data' => ['config' => ['options' => $applyOptions]]]], 'discount_amount' => ['arguments' => ['data' => ['config' => ['value' => '0']]]], 'discount_qty' => ['arguments' => ['data' => ['config' => ['value' => '0']]]], 'apply_to_shipping' => ['arguments' => ['data' => ['config' => ['options' => [['label' => __('Yes'), 'value' => '1'], ['label' => __('No'), 'value' => '0']]]]]], 'stop_rules_processing' => ['arguments' => ['data' => ['config' => ['options' => [['label' => __('Yes'), 'value' => '1'], ['label' => __('No'), 'value' => '0']]]]]]]], 'labels' => ['children' => ['store_labels[0]' => ['arguments' => ['data' => ['config' => ['value' => isset($labels[0]) ? $labels[0] : '']]]]]]];
}
示例15: _prepareForm
/**
* Prepare rating edit form
*
* @return $this
*/
protected function _prepareForm()
{
/** @var \Magento\Framework\Data\Form $form */
$form = $this->_formFactory->create();
$this->setForm($form);
$fieldset = $form->addFieldset('rating_form', array('legend' => __('Rating Title')));
$fieldset->addField('rating_code', 'text', array('name' => 'rating_code', 'label' => __('Default Value'), 'class' => 'required-entry', 'required' => true));
foreach ($this->_systemStore->getStoreCollection() as $store) {
$fieldset->addField('rating_code_' . $store->getId(), 'text', array('label' => $store->getName(), 'name' => 'rating_codes[' . $store->getId() . ']'));
}
if ($this->_session->getRatingData()) {
$form->setValues($this->_session->getRatingData());
$data = $this->_session->getRatingData();
if (isset($data['rating_codes'])) {
$this->_setRatingCodes($data['rating_codes']);
}
$this->_session->setRatingData(null);
} elseif ($this->_coreRegistry->registry('rating_data')) {
$form->setValues($this->_coreRegistry->registry('rating_data')->getData());
if ($this->_coreRegistry->registry('rating_data')->getRatingCodes()) {
$this->_setRatingCodes($this->_coreRegistry->registry('rating_data')->getRatingCodes());
}
}
if ($this->_coreRegistry->registry('rating_data')) {
$collection = $this->_optionFactory->create()->getResourceCollection()->addRatingFilter($this->_coreRegistry->registry('rating_data')->getId())->load();
$i = 1;
foreach ($collection->getItems() as $item) {
$fieldset->addField('option_code_' . $item->getId(), 'hidden', array('required' => true, 'name' => 'option_title[' . $item->getId() . ']', 'value' => $item->getCode() ? $item->getCode() : $i));
$i++;
}
} else {
for ($i = 1; $i <= 5; $i++) {
$fieldset->addField('option_code_' . $i, 'hidden', array('required' => true, 'name' => 'option_title[add_' . $i . ']', 'value' => $i));
}
}
$fieldset = $form->addFieldset('visibility_form', array('legend' => __('Rating Visibility')));
if (!$this->_storeManager->isSingleStoreMode()) {
$field = $fieldset->addField('stores', 'multiselect', array('label' => __('Visible In'), 'name' => 'stores[]', 'values' => $this->_systemStore->getStoreValuesForForm()));
$renderer = $this->getLayout()->createBlock('Magento\\Backend\\Block\\Store\\Switcher\\Form\\Renderer\\Fieldset\\Element');
$field->setRenderer($renderer);
if ($this->_coreRegistry->registry('rating_data')) {
$form->getElement('stores')->setValue($this->_coreRegistry->registry('rating_data')->getStores());
}
}
$fieldset->addField('is_active', 'checkbox', array('label' => __('Is Active'), 'name' => 'is_active', 'value' => 1));
$fieldset->addField('position', 'text', array('label' => __('Sort Order'), 'name' => 'position'));
if ($this->_coreRegistry->registry('rating_data')) {
$form->getElement('position')->setValue($this->_coreRegistry->registry('rating_data')->getPosition());
$form->getElement('is_active')->setIsChecked($this->_coreRegistry->registry('rating_data')->getIsActive());
}
return parent::_prepareForm();
}