本文整理汇总了PHP中Magento\Framework\Data\Form::addFieldset方法的典型用法代码示例。如果您正苦于以下问题:PHP Form::addFieldset方法的具体用法?PHP Form::addFieldset怎么用?PHP Form::addFieldset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\Data\Form
的用法示例。
在下文中一共展示了Form::addFieldset方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _prepareStoreFieldset
/**
* Prepare group specific fieldset
*
* @param \Magento\Framework\Data\Form $form
* @return void
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
protected function _prepareStoreFieldset(\Magento\Framework\Data\Form $form)
{
$groupModel = $this->_coreRegistry->registry('store_data');
$postData = $this->_coreRegistry->registry('store_post_data');
if ($postData) {
$groupModel->setData($postData['group']);
}
$fieldset = $form->addFieldset('group_fieldset', ['legend' => __('Store Information')]);
$storeAction = $this->_coreRegistry->registry('store_action');
if ($storeAction == 'edit' || $storeAction == 'add') {
$websites = $this->_websiteFactory->create()->getCollection()->toOptionArray();
$fieldset->addField('group_website_id', 'select', ['name' => 'group[website_id]', 'label' => __('Web Site'), 'value' => $groupModel->getWebsiteId(), 'values' => $websites, 'required' => true, 'disabled' => $groupModel->isReadOnly()]);
if ($groupModel->getId() && $groupModel->getWebsite()->getDefaultGroupId() == $groupModel->getId()) {
if ($groupModel->getWebsite()->getIsDefault() || $groupModel->getWebsite()->getGroupsCount() == 1) {
$form->getElement('group_website_id')->setDisabled(true);
$fieldset->addField('group_hidden_website_id', 'hidden', ['name' => 'group[website_id]', 'no_span' => true, 'value' => $groupModel->getWebsiteId()]);
} else {
$fieldset->addField('group_original_website_id', 'hidden', ['name' => 'group[original_website_id]', 'no_span' => true, 'value' => $groupModel->getWebsiteId()]);
}
}
}
$fieldset->addField('group_name', 'text', ['name' => 'group[name]', 'label' => __('Name'), 'value' => $groupModel->getName(), 'required' => true, 'disabled' => $groupModel->isReadOnly()]);
$categories = $this->_category->toOptionArray();
$fieldset->addField('group_root_category_id', 'select', ['name' => 'group[root_category_id]', 'label' => __('Root Category'), 'value' => $groupModel->getRootCategoryId(), 'values' => $categories, 'required' => true, 'disabled' => $groupModel->isReadOnly()]);
if ($this->_coreRegistry->registry('store_action') == 'edit') {
$storeActive = 1;
$stores = $this->_storeFactory->create()->getCollection()->addGroupFilter($groupModel->getId())->addStatusFilter($storeActive)->toOptionArray();
$fieldset->addField('group_default_store_id', 'select', ['name' => 'group[default_store_id]', 'label' => __('Default Store View'), 'value' => $groupModel->getDefaultStoreId(), 'values' => $stores, 'required' => false, 'disabled' => $groupModel->isReadOnly()]);
}
$fieldset->addField('group_group_id', 'hidden', ['name' => 'group[group_id]', 'no_span' => true, 'value' => $groupModel->getId()]);
}
示例2: addGoogleoptimizerFields
/**
* Prepare form
*
* @param DataForm $form
* @param ModelCode|null $experimentCodeModel
* @param string $formName
* @return void
*/
public function addGoogleoptimizerFields(DataForm $form, ModelCode $experimentCodeModel = null, $formName = '')
{
$fieldset = $form->addFieldset('googleoptimizer_fields', ['legend' => __('Google Analytics Content Experiments Code')]);
$fieldset->addField('experiment_script', 'textarea', ['name' => 'experiment_script', 'label' => __('Experiment Code'), 'value' => $experimentCodeModel ? $experimentCodeModel->getExperimentScript() : '', 'class' => 'textarea googleoptimizer', 'required' => false, 'note' => __('Experiment code should be added to the original page only.'), 'data-form-part' => $formName]);
$fieldset->addField('code_id', 'hidden', ['name' => 'code_id', 'value' => $experimentCodeModel ? $experimentCodeModel->getCodeId() : '', 'required' => false, 'data-form-part' => $formName]);
$form->setFieldNameSuffix('google_experiment');
}
示例3: _addThemeFieldset
/**
* Add theme fieldset
*
* @param \Magento\Framework\Data\Form $form
* @param array $formData
* @param ThemeInterface $theme
* @return $this
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
protected function _addThemeFieldset($form, $formData, ThemeInterface $theme)
{
$themeFieldset = $form->addFieldset('theme', ['legend' => __('Theme Settings')]);
$this->_addElementTypes($themeFieldset);
if (isset($formData['theme_id'])) {
$themeFieldset->addField('theme_id', 'hidden', ['name' => 'theme_id']);
}
/** @var \Magento\Theme\Model\Theme\Collection $themesCollections */
$themesCollections = $this->_objectManager->create('Magento\\Theme\\Model\\Theme\\Collection');
/** @var \Magento\Framework\Json\Helper\Data $helper */
$helper = $this->_objectManager->get('Magento\\Framework\\Json\\Helper\\Data');
$onChangeScript = sprintf('parentThemeOnChange(this.value, %s)', str_replace('"', '\'', $helper->jsonEncode($this->_getDefaultsInherited($themesCollections->addDefaultPattern()))));
/** @var ThemeInterface $parentTheme */
$parentTheme = $this->_objectManager->create('Magento\\Framework\\View\\Design\\ThemeInterface');
if (!empty($formData['parent_id'])) {
$parentTheme->load($formData['parent_id']);
}
if ($this->_getCurrentTheme()->isObjectNew()) {
$themeFieldset->addField('parent_id', 'select', ['label' => __('Parent Theme'), 'title' => __('Parent Theme'), 'name' => 'parent_id', 'values' => $themesCollections->toOptionArray(!$parentTheme->getId()), 'required' => true, 'class' => 'no-changes', 'onchange' => $onChangeScript]);
} elseif (!empty($formData['parent_id'])) {
$themeFieldset->addField('parent_title', 'note', ['label' => __('Parent Theme'), 'title' => __('Parent Theme'), 'name' => 'parent_title', 'text' => $parentTheme->getId() ? $parentTheme->getThemeTitle() : '']);
}
if (!empty($formData['theme_path'])) {
$themeFieldset->addField('theme_path', 'label', ['label' => __('Theme Path'), 'title' => __('Theme Path'), 'name' => 'theme_code']);
}
$themeFieldset->addField('theme_title', $this->_getFieldTextType(), ['label' => __('Theme Title'), 'title' => __('Theme Title'), 'name' => 'theme_title', 'required' => $this->_isFieldAttrRequired()]);
if ($this->_isThemeEditable) {
$themeFieldset->addField('preview_image', 'image', ['label' => __('Theme Preview Image'), 'title' => __('Theme Preview Image'), 'name' => 'preview', 'required' => false, 'note' => $this->_getPreviewImageNote(), 'theme' => $theme]);
} elseif ($theme->hasPreviewImage()) {
$themeFieldset->addField('preview_image', 'note', ['label' => __('Theme Preview Image'), 'title' => __('Theme Preview Image'), 'name' => 'preview', 'after_element_html' => '<a href="' . $theme->getThemeImage()->getPreviewImageUrl() . '" onclick="imagePreview(\'theme_preview_image\'); return false;">' . '<img width="50" src="' . $theme->getThemeImage()->getPreviewImageUrl() . '" id="theme_preview_image" /></a>']);
}
return $this;
}
示例4: _prepareStoreFieldset
/**
* Prepare store specific fieldset
*
* @param \Magento\Framework\Data\Form $form
* @return void
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
protected function _prepareStoreFieldset(\Magento\Framework\Data\Form $form)
{
$storeModel = $this->_coreRegistry->registry('store_data');
$postData = $this->_coreRegistry->registry('store_post_data');
if ($postData) {
$storeModel->setData($postData['store']);
}
$fieldset = $form->addFieldset('store_fieldset', array('legend' => __('Store View Information')));
$storeAction = $this->_coreRegistry->registry('store_action');
if ($storeAction == 'edit' || $storeAction == 'add') {
$fieldset->addField('store_group_id', 'select', array('name' => 'store[group_id]', 'label' => __('Store'), 'value' => $storeModel->getGroupId(), 'values' => $this->_getStoreGroups(), 'required' => true, 'disabled' => $storeModel->isReadOnly()));
if ($storeModel->getId() && $storeModel->getGroup()->getDefaultStoreId() == $storeModel->getId()) {
if ($storeModel->getGroup() && $storeModel->getGroup()->getStoresCount() > 1) {
$form->getElement('store_group_id')->setDisabled(true);
$fieldset->addField('store_hidden_group_id', 'hidden', array('name' => 'store[group_id]', 'no_span' => true, 'value' => $storeModel->getGroupId()));
} else {
$fieldset->addField('store_original_group_id', 'hidden', array('name' => 'store[original_group_id]', 'no_span' => true, 'value' => $storeModel->getGroupId()));
}
}
}
$fieldset->addField('store_name', 'text', array('name' => 'store[name]', 'label' => __('Name'), 'value' => $storeModel->getName(), 'required' => true, 'disabled' => $storeModel->isReadOnly()));
$fieldset->addField('store_code', 'text', array('name' => 'store[code]', 'label' => __('Code'), 'value' => $storeModel->getCode(), 'required' => true, 'disabled' => $storeModel->isReadOnly()));
$fieldset->addField('store_is_active', 'select', array('name' => 'store[is_active]', 'label' => __('Status'), 'value' => $storeModel->getIsActive(), 'options' => array(0 => __('Disabled'), 1 => __('Enabled')), 'required' => true, 'disabled' => $storeModel->isReadOnly()));
$fieldset->addField('store_sort_order', 'text', array('name' => 'store[sort_order]', 'label' => __('Sort Order'), 'value' => $storeModel->getSortOrder(), 'required' => false, 'disabled' => $storeModel->isReadOnly()));
$fieldset->addField('store_is_default', 'hidden', array('name' => 'store[is_default]', 'no_span' => true, 'value' => $storeModel->getIsDefault()));
$fieldset->addField('store_store_id', 'hidden', array('name' => 'store[store_id]', 'no_span' => true, 'value' => $storeModel->getId(), 'disabled' => $storeModel->isReadOnly()));
}
示例5: _addStoresFieldset
/**
* Add Fieldset with Store labels
*
* @param \Magento\Sales\Model\Order\Status $model
* @param \Magento\Framework\Data\Form $form
* @return void
*/
protected function _addStoresFieldset($model, $form)
{
$labels = $model ? $model->getStoreLabels() : [];
$fieldset = $form->addFieldset('store_labels_fieldset', ['legend' => __('Store View Specific Labels'), 'class' => 'store-scope']);
$renderer = $this->getLayout()->createBlock('Magento\\Backend\\Block\\Store\\Switcher\\Form\\Renderer\\Fieldset');
$fieldset->setRenderer($renderer);
foreach ($this->_storeManager->getWebsites() as $website) {
$fieldset->addField("w_{$website->getId()}_label", 'note', ['label' => $website->getName(), 'fieldset_html_class' => 'website']);
foreach ($website->getGroups() as $group) {
$stores = $group->getStores();
if (count($stores) == 0) {
continue;
}
$fieldset->addField("sg_{$group->getId()}_label", 'note', ['label' => $group->getName(), 'fieldset_html_class' => 'store-group']);
foreach ($stores as $store) {
$fieldset->addField("store_label_{$store->getId()}", 'text', ['name' => 'store_labels[' . $store->getId() . ']', 'required' => false, 'label' => $store->getName(), 'value' => isset($labels[$store->getId()]) ? $labels[$store->getId()] : '', 'fieldset_html_class' => 'store']);
}
}
}
}
示例6: _prepareStoreFieldset
/**
* Prepare website specific fieldset
*
* @param \Magento\Framework\Data\Form $form
* @return void
*/
protected function _prepareStoreFieldset(\Magento\Framework\Data\Form $form)
{
$websiteModel = $this->_coreRegistry->registry('store_data');
$postData = $this->_coreRegistry->registry('store_post_data');
if ($postData) {
$websiteModel->setData($postData['website']);
}
$fieldset = $form->addFieldset('website_fieldset', array('legend' => __('Web Site Information')));
/* @var $fieldset \Magento\Framework\Data\Form */
$fieldset->addField('website_name', 'text', array('name' => 'website[name]', 'label' => __('Name'), 'value' => $websiteModel->getName(), 'required' => true, 'disabled' => $websiteModel->isReadOnly()));
$fieldset->addField('website_code', 'text', array('name' => 'website[code]', 'label' => __('Code'), 'value' => $websiteModel->getCode(), 'required' => true, 'disabled' => $websiteModel->isReadOnly()));
$fieldset->addField('website_sort_order', 'text', array('name' => 'website[sort_order]', 'label' => __('Sort Order'), 'value' => $websiteModel->getSortOrder(), 'required' => false, 'disabled' => $websiteModel->isReadOnly()));
if ($this->_coreRegistry->registry('store_action') == 'edit') {
$groups = $this->_groupFactory->create()->getCollection()->addWebsiteFilter($websiteModel->getId())->setWithoutStoreViewFilter()->toOptionArray();
$fieldset->addField('website_default_group_id', 'select', array('name' => 'website[default_group_id]', 'label' => __('Default Store'), 'value' => $websiteModel->getDefaultGroupId(), 'values' => $groups, 'required' => false, 'disabled' => $websiteModel->isReadOnly()));
}
if (!$websiteModel->getIsDefault() && $websiteModel->getStoresCount()) {
$fieldset->addField('is_default', 'checkbox', array('name' => 'website[is_default]', 'label' => __('Set as Default'), 'value' => 1, 'disabled' => $websiteModel->isReadOnly()));
} else {
$fieldset->addField('is_default', 'hidden', array('name' => 'website[is_default]', 'value' => $websiteModel->getIsDefault()));
}
$fieldset->addField('website_website_id', 'hidden', array('name' => 'website[website_id]', 'value' => $websiteModel->getId()));
}
示例7: _addDetailsFieldset
/**
* Add fieldset with integration details. This fieldset is available for existing integrations only.
*
* @param \Magento\Framework\Data\Form $form
* @param array $integrationData
* @return void
*/
protected function _addDetailsFieldset($form, $integrationData)
{
if (isset($integrationData[self::DATA_ID])) {
$fieldset = $form->addFieldset('details_fieldset', ['legend' => __('Integration Details')]);
/** @var \Magento\Integration\Block\Adminhtml\Integration\Tokens $tokensBlock */
$tokensBlock = $this->getChildBlock('integration_tokens');
foreach ($tokensBlock->getFormFields() as $field) {
$fieldset->addField($field['name'], $field['type'], $field['metadata']);
}
}
}
示例8: _initFormElements
/**
* Initialize form elements
*
* @param Configuration $controlsConfig
* @param Form $form
* @return $this
*/
protected function _initFormElements($controlsConfig, $form)
{
$hintMessage = __('Please enter values for height and width.' . ' Use the chain icon if you want height and width to match.' . ' Be sure to see how it looks in your store.' . ' You may need to update your custom CSS file.');
$form->addField('information_hint', 'note', ['after_element_html' => '<p class="note">' . $hintMessage . '</p>']);
$whiteBorder = $controlsConfig->getControlData('product_image_border');
if ($whiteBorder) {
$this->_addWhiteBorderElement($whiteBorder);
}
$controls = $controlsConfig->getAllControlsData();
foreach ($controls as $name => $control) {
if ($control['type'] != 'image-sizing') {
continue;
}
$this->_addImageSizeFieldset($name, $control);
}
$fieldset = $form->addFieldset('save_image_sizing_fieldset', ['name' => 'save_image_sizing_fieldset', 'fieldset_type' => 'field', 'class' => 'save_image_sizing']);
$this->_addElementTypes($fieldset);
if ($whiteBorder || $controls) {
$fieldset->addField('save_image_sizing', 'button_button', ['name' => 'save_image_sizing', 'title' => __('Update'), 'value' => __('Update'), 'data-mage-init' => $this->escapeHtml(json_encode(['button' => ['event' => 'saveForm', 'target' => 'body']]))]);
}
return $this;
}
示例9: createDisplayFieldset
/**
* Append the "Slider Display Configuration" fieldset to the tab.
*
* @param Form $form Target form.
* @param Front $subject Target tab.
*
* @return Fieldset
*/
private function createDisplayFieldset(Form $form, Front $subject)
{
$fieldset = $form->addFieldset('elasticsuite_catalog_attribute_display_fieldset', ['legend' => __('Slider Display Configuration'), 'collapsable' => $subject->getRequest()->has('popup')], 'elasticsuite_catalog_attribute_fieldset');
return $fieldset;
}