本文整理汇总了PHP中Magento\Backend\Block\Widget\Form\Generic::_prepareForm方法的典型用法代码示例。如果您正苦于以下问题:PHP Generic::_prepareForm方法的具体用法?PHP Generic::_prepareForm怎么用?PHP Generic::_prepareForm使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Backend\Block\Widget\Form\Generic
的用法示例。
在下文中一共展示了Generic::_prepareForm方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _prepareForm
/**
* Prepare form before rendering HTML
*
* @return $this
* @SuppressWarnings(PHPMD.NPathComplexity)
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
protected function _prepareForm()
{
$model = $this->_coreRegistry->registry('current_lapisbard_storelocator_locations');
/** @var \Magento\Framework\Data\Form $form */
$form = $this->_formFactory->create();
$form->setHtmlIdPrefix('item_');
$countries = [['value' => 'UK', 'label' => __('UK')], ['value' => 'India', 'label' => __('India')]];
$yesno = [['value' => 'Enabled', 'label' => __('Enabled')], ['value' => 'Disabled', 'label' => __('Disabled')]];
$fieldset = $form->addFieldset('base_fieldset', ['legend' => __('Location Information')]);
if ($model->getId()) {
$fieldset->addField('id', 'hidden', ['name' => 'id']);
}
$fieldset->addField('store_title', 'text', ['name' => 'store_title', 'label' => __('Store Title'), 'title' => __('Store Title'), 'required' => true]);
$fieldset->addField('address', 'text', ['name' => 'address', 'label' => __('Address'), 'title' => __('Address'), 'required' => true]);
$fieldset->addField('city', 'text', ['name' => 'city', 'label' => __('City'), 'title' => __('City'), 'required' => false]);
$fieldset->addField('state', 'text', ['name' => 'state', 'label' => __('State'), 'title' => __('State'), 'required' => true]);
$fieldset->addField('pincode', 'text', ['name' => 'pincode', 'label' => __('Pin Code'), 'title' => __('Pin Code'), 'required' => true]);
$fieldset->addField('country', 'select', ['name' => 'country', 'label' => __('Country'), 'title' => __('Country'), 'values' => $countries]);
$fieldset->addField('phone', 'text', ['name' => 'phone', 'label' => __('Phone Number'), 'title' => __('Phone Number'), 'required' => true]);
$fieldset->addField('email', 'text', ['name' => 'email', 'label' => __('Email'), 'title' => __('Email'), 'required' => false]);
$fieldset->addField('is_enable', 'select', ['name' => 'is_enable', 'label' => __('Status'), 'title' => __('Status'), 'values' => $yesno]);
$form->setValues($model->getData());
$this->setForm($form);
return parent::_prepareForm();
}
示例2: _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();
}
示例3: _prepareForm
/**
* {@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: _prepareForm
/**
* Prepare form
*
* @return $this
*/
protected function _prepareForm()
{
/** @var $model \Magento\Cms\Model\Page */
$model = $this->_coreRegistry->registry('cms_page');
/*
* Checking if user have permissions to save information
*/
if ($this->_isAllowedAction('Magento_Cms::save')) {
$isElementDisabled = false;
} else {
$isElementDisabled = true;
}
/** @var \Magento\Framework\Data\Form $form */
$form = $this->_formFactory->create();
$form->setHtmlIdPrefix('page_');
$fieldset = $form->addFieldset('content_fieldset', ['legend' => __('Content'), 'class' => 'fieldset-wide']);
$wysiwygConfig = $this->_wysiwygConfig->getConfig(['tab_id' => $this->getTabId()]);
$fieldset->addField('content_heading', 'text', ['name' => 'content_heading', 'label' => __('Content Heading'), 'title' => __('Content Heading'), 'disabled' => $isElementDisabled]);
$contentField = $fieldset->addField('content', 'editor', ['name' => 'content', 'style' => 'height:36em;', 'required' => true, 'disabled' => $isElementDisabled, 'config' => $wysiwygConfig]);
// Setting custom renderer for content field to remove label column
$renderer = $this->getLayout()->createBlock('Magento\\Backend\\Block\\Widget\\Form\\Renderer\\Fieldset\\Element')->setTemplate('Magento_Cms::page/edit/form/renderer/content.phtml');
$contentField->setRenderer($renderer);
$this->_eventManager->dispatch('adminhtml_cms_page_edit_tab_content_prepare_form', ['form' => $form]);
$form->setValues($model->getData());
$this->setForm($form);
return parent::_prepareForm();
}
示例5: _prepareForm
/**
* {@inheritdoc}
*/
protected function _prepareForm()
{
$userId = $this->_authSession->getUser()->getId();
$user = $this->_userFactory->create()->load($userId);
$user->unsetData('password');
/** @var \Magento\Framework\Data\Form $form */
$form = $this->_formFactory->create();
$fieldset = $form->addFieldset('base_fieldset', ['legend' => __('Account Information')]);
$fieldset->addField('username', 'text', ['name' => 'username', 'label' => __('User Name'), 'title' => __('User Name'), 'required' => true]);
$fieldset->addField('firstname', 'text', ['name' => 'firstname', 'label' => __('First Name'), 'title' => __('First Name'), 'required' => true]);
$fieldset->addField('lastname', 'text', ['name' => 'lastname', 'label' => __('Last Name'), 'title' => __('Last Name'), 'required' => true]);
$fieldset->addField('user_id', 'hidden', ['name' => 'user_id']);
$fieldset->addField('email', 'text', ['name' => 'email', 'label' => __('Email'), 'title' => __('User Email'), 'required' => true]);
$fieldset->addField('password', 'password', ['name' => 'password', 'label' => __('New Password'), 'title' => __('New Password'), 'class' => 'input-text validate-admin-password']);
$fieldset->addField('confirmation', 'password', ['name' => 'password_confirmation', 'label' => __('Password Confirmation'), 'class' => 'input-text validate-cpassword']);
$fieldset->addField('interface_locale', 'select', ['name' => 'interface_locale', 'label' => __('Interface Locale'), 'title' => __('Interface Locale'), 'values' => $this->_localeLists->getTranslatedOptionLocales(), 'class' => 'select']);
$verificationFieldset = $form->addFieldset('current_user_verification_fieldset', ['legend' => __('Current User Identity Verification')]);
$verificationFieldset->addField(self::IDENTITY_VERIFICATION_PASSWORD_FIELD, 'password', ['name' => self::IDENTITY_VERIFICATION_PASSWORD_FIELD, 'label' => __('Your Password'), 'id' => self::IDENTITY_VERIFICATION_PASSWORD_FIELD, 'title' => __('Your Password'), 'class' => 'input-text validate-current-password required-entry', 'required' => true]);
$data = $user->getData();
unset($data[self::IDENTITY_VERIFICATION_PASSWORD_FIELD]);
$form->setValues($data);
$form->setAction($this->getUrl('adminhtml/system_account/save'));
$form->setMethod('post');
$form->setUseContainer(true);
$form->setId('edit_form');
$this->setForm($form);
return parent::_prepareForm();
}
示例6: _prepareForm
/**
* Prepare form
*
* @return $this
*/
protected function _prepareForm()
{
/** @var \Swissup\Email\Model\Service $model */
$model = $this->_getModel();
$isElementDisabled = !$this->_isAllowedAction('Swissup_Email::service_save');
/** @var \Magento\Framework\Data\Form $form */
$form = $this->_formFactory->create(['data' => ['id' => 'edit_form', 'action' => $this->getData('action'), 'method' => 'post']]);
$form->setHtmlIdPrefix('service_');
$fieldset = $form->addFieldset('base_fieldset', ['legend' => __('Service Information'), 'class' => 'fieldset-wide']);
// $fieldset = $form->addFieldset(
// 'base_fieldset',
// ['legend' => __('Information'), 'class' => 'fieldset-wide']
// );
// \Zend_Debug::dump(get_class_methods($this));
// \Zend_Debug::dump(get_class_methods($fieldset));
$fieldset->addField('id', 'hidden', ['name' => 'id']);
$fieldset->addField('name', 'text', ['name' => 'name', 'label' => __('Name'), 'title' => __('Name'), 'required' => true, 'disabled' => $isElementDisabled]);
$fieldset->addField('type', 'select', ['label' => __('Type'), 'title' => __('Type'), 'name' => 'type', 'required' => true, 'options' => $model->getTypes(), 'disabled' => $isElementDisabled]);
$fieldset->addField('user', 'text', ['name' => 'user', 'label' => __('User (key)'), 'title' => __('User (key)'), 'disabled' => $isElementDisabled]);
$fieldset->addField('password', 'password', ['name' => 'password', 'label' => __('Password (secure key)'), 'title' => __('Password (secure key)'), 'disabled' => $isElementDisabled]);
$fieldset->addField('email', 'text', ['name' => 'email', 'label' => __('Email (from)'), 'title' => __('Email'), 'disabled' => $isElementDisabled]);
$fieldset->addField('host', 'text', ['name' => 'host', 'label' => __('Host'), 'title' => __('Host'), 'disabled' => $isElementDisabled]);
$fieldset->addField('port', 'text', ['name' => 'port', 'label' => __('Port'), 'title' => __('Port'), 'disabled' => $isElementDisabled]);
$fieldset->addField('secure', 'select', ['label' => __('Secure'), 'title' => __('Secure'), 'name' => 'secure', 'options' => $model->getSecures(), 'disabled' => $isElementDisabled]);
$fieldset->addField('auth', 'select', ['label' => __('Auth Type'), 'title' => __('Auth Type'), 'name' => 'auth', 'options' => $model->getAuthTypes(), 'disabled' => $isElementDisabled]);
$fieldset->addField('status', 'select', ['label' => __('Status'), 'title' => __('Status'), 'name' => 'status', 'options' => $model->getStatuses(), 'disabled' => $isElementDisabled]);
$this->setForm($form);
$form->setValues($model->getData());
$form->setUseContainer(true);
return parent::_prepareForm();
}
示例7: _prepareForm
/**
* Add fieldsets
*
* @return $this
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
protected function _prepareForm()
{
/** @var \Magento\Framework\Data\Form $form */
$form = $this->_formFactory->create(['data' => ['id' => 'edit_form', 'action' => $this->getUrl('adminhtml/*/validate'), 'method' => 'post', 'enctype' => 'multipart/form-data']]);
// base fieldset
$fieldsets['base'] = $form->addFieldset('base_fieldset', ['legend' => __('Import Settings')]);
$fieldsets['base']->addField('entity', 'select', ['name' => 'entity', 'title' => __('Entity Type'), 'label' => __('Entity Type'), 'required' => true, 'onchange' => 'varienImport.handleEntityTypeSelector();', 'values' => $this->_entityFactory->create()->toOptionArray(), 'after_element_html' => $this->getDownloadSampleFileHtml()]);
// add behaviour fieldsets
$uniqueBehaviors = $this->_importModel->getUniqueEntityBehaviors();
foreach ($uniqueBehaviors as $behaviorCode => $behaviorClass) {
$fieldsets[$behaviorCode] = $form->addFieldset($behaviorCode . '_fieldset', ['legend' => __('Import Behavior'), 'class' => 'no-display']);
/** @var $behaviorSource \Magento\ImportExport\Model\Source\Import\AbstractBehavior */
$fieldsets[$behaviorCode]->addField($behaviorCode, 'select', ['name' => 'behavior', 'title' => __('Import Behavior'), 'label' => __('Import Behavior'), 'required' => true, 'disabled' => true, 'values' => $this->_behaviorFactory->create($behaviorClass)->toOptionArray(), 'class' => $behaviorCode, 'onchange' => 'varienImport.handleImportBehaviorSelector();', 'note' => ' ']);
$fieldsets[$behaviorCode]->addField($behaviorCode . \Magento\ImportExport\Model\Import::FIELD_NAME_VALIDATION_STRATEGY, 'select', ['name' => \Magento\ImportExport\Model\Import::FIELD_NAME_VALIDATION_STRATEGY, 'title' => __(' '), 'label' => __(' '), 'required' => true, 'class' => $behaviorCode, 'disabled' => true, 'values' => [ProcessingErrorAggregatorInterface::VALIDATION_STRATEGY_STOP_ON_ERROR => 'Stop on Error', ProcessingErrorAggregatorInterface::VALIDATION_STRATEGY_SKIP_ERRORS => 'Skip error entries'], 'after_element_html' => $this->getDownloadSampleFileHtml()]);
$fieldsets[$behaviorCode]->addField($behaviorCode . '_' . \Magento\ImportExport\Model\Import::FIELD_NAME_ALLOWED_ERROR_COUNT, 'text', ['name' => \Magento\ImportExport\Model\Import::FIELD_NAME_ALLOWED_ERROR_COUNT, 'label' => __('Allowed Errors Count'), 'title' => __('Allowed Errors Count'), 'required' => true, 'disabled' => true, 'value' => 10, 'class' => $behaviorCode . ' validate-number validate-greater-than-zero input-text', 'note' => __('Please specify number of errors to halt import process')]);
$fieldsets[$behaviorCode]->addField($behaviorCode . '_' . \Magento\ImportExport\Model\Import::FIELD_FIELD_SEPARATOR, 'text', ['name' => \Magento\ImportExport\Model\Import::FIELD_FIELD_SEPARATOR, 'label' => __('Field separator'), 'title' => __('Field separator'), 'required' => true, 'disabled' => true, 'class' => $behaviorCode, 'value' => ',']);
$fieldsets[$behaviorCode]->addField($behaviorCode . \Magento\ImportExport\Model\Import::FIELD_FIELD_MULTIPLE_VALUE_SEPARATOR, 'text', ['name' => \Magento\ImportExport\Model\Import::FIELD_FIELD_MULTIPLE_VALUE_SEPARATOR, 'label' => __('Multiple value separator'), 'title' => __('Multiple value separator'), 'required' => true, 'disabled' => true, 'class' => $behaviorCode, 'value' => ',']);
}
// fieldset for file uploading
$fieldsets['upload'] = $form->addFieldset('upload_file_fieldset', ['legend' => __('File to Import'), 'class' => 'no-display']);
$fieldsets['upload']->addField(\Magento\ImportExport\Model\Import::FIELD_NAME_SOURCE_FILE, 'file', ['name' => \Magento\ImportExport\Model\Import::FIELD_NAME_SOURCE_FILE, 'label' => __('Select File to Import'), 'title' => __('Select File to Import'), 'required' => true, 'class' => 'input-file']);
$fieldsets['upload']->addField(\Magento\ImportExport\Model\Import::FIELD_NAME_IMG_FILE_DIR, 'text', ['name' => \Magento\ImportExport\Model\Import::FIELD_NAME_IMG_FILE_DIR, 'label' => __('Images File Directory'), 'title' => __('Images File Directory'), 'required' => false, 'class' => 'input-text', 'note' => __('For Type "Local Server" use relative path to Magento installation,
e.g. var/export, var/import, var/export/some/dir')]);
$form->setUseContainer(true);
$this->setForm($form);
return parent::_prepareForm();
}
示例8: _prepareForm
/**
* Prepare form
*
* @return $this
*/
protected function _prepareForm()
{
/* @var $model \Magento\Cms\Model\Page */
$model = $this->_coreRegistry->registry('testimonial');
$isElementDisabled = false;
/** @var \Magento\Framework\Data\Form $form */
$form = $this->_formFactory->create();
$form->setHtmlIdPrefix('page_');
$fieldset = $form->addFieldset('base_fieldset', array('legend' => __('Testimonial Information')));
if ($model->getId()) {
$fieldset->addField('testimonial_id', 'hidden', array('name' => 'testimonial_id'));
}
$fieldset->addField('firstname', 'text', array('name' => 'firstname', 'label' => __('First Name'), 'title' => __('First Name'), 'required' => true, 'disabled' => $isElementDisabled));
$fieldset->addField('lastname', 'text', array('name' => 'lastname', 'label' => __('Last Name'), 'title' => __('Last Name'), 'required' => true, 'disabled' => $isElementDisabled));
$fieldset->addField('email', 'text', array('name' => 'email', 'label' => __('Email'), 'title' => __('Email'), 'required' => true, 'disabled' => $isElementDisabled));
$fieldset->addField('description', 'textarea', array('name' => 'description', 'label' => __('Description Name'), 'title' => __('Description Name'), 'required' => true, 'disabled' => $isElementDisabled));
$fieldset->addField('status', 'select', array('label' => __('Status'), 'title' => __('Page Status'), 'name' => 'status', 'required' => true, 'options' => $model->getAvailableStatuses(), 'disabled' => $isElementDisabled));
if (!$model->getId()) {
$model->setData('status', $isElementDisabled ? '2' : '1');
}
//$this->_eventManager->dispatch('adminhtml_cms_page_edit_tab_main_prepare_form', array('form' => $form));
/*if($model->getData('image'))
$model->setData('image','testimonialslider/images'.$model->getData('image'));*/
$form->setValues($model->getData());
$this->setForm($form);
return parent::_prepareForm();
}
示例9: _prepareForm
/**
* @return $this
* @throws \Magento\Framework\Exception\LocalizedException
*/
protected function _prepareForm()
{
$model = $this->_coreRegistry->registry('banner');
$form = $this->_formFactory->create();
$form->setHtmlIdPrefix($this->_banner->getFormFieldHtmlIdPrefix());
$fieldset = $form->addFieldset('base_fieldset', ['legend' => __('Banner Information')]);
if ($model->getId()) {
$fieldset->addField('banner_id', 'hidden', ['name' => 'banner_id']);
}
$fieldset->addField('name', 'text', ['name' => 'name', 'label' => __('Banner Name'), 'title' => __('Banner Name'), 'required' => true]);
$fieldset->addField('status', 'select', ['label' => __('Status'), 'title' => __('Status'), 'name' => 'status', 'required' => true, 'options' => ['1' => __('Enabled'), '0' => __('Disabled')]]);
if (!$model->getId()) {
$model->setData('status', '1');
}
$type = $fieldset->addField('type', 'select', ['label' => __('Status'), 'title' => __('Status'), 'name' => 'type', 'required' => true, 'options' => ['1' => __('Image'), '0' => __('Video')]]);
$imageField = $fieldset->addField('image', 'image', ['title' => __('Banner Image'), 'label' => __('Banner Image'), 'name' => 'image', 'note' => 'Allow image type: jpg, jpeg, gif, png']);
$imageAltText = $fieldset->addField('image_alt', 'text', ['title' => __('Alt Text'), 'label' => __('Alt Text'), 'name' => 'image_alt', 'note' => 'Used for SEO']);
$imageUrl = $fieldset->addField('url', 'text', ['title' => __('URL'), 'label' => __('URL'), 'name' => 'url']);
$imageTarget = $fieldset->addField('target', 'select', ['label' => __('Target'), 'name' => 'target', 'values' => [['value' => \Magebase\Carousel\Model\Banner::BANNER_TARGET_SELF, 'label' => __('New Window with Browser Navigation')], ['value' => \Magebase\Carousel\Model\Banner::BANNER_TARGET_PARENT, 'label' => __('Parent Window with Browser Navigation')], ['value' => \Magebase\Carousel\Model\Banner::BANNER_TARGET_BLANK, 'label' => __('New Window without Browser Navigation')]]]);
$videoUrl = $fieldset->addField('video', 'text', ['title' => __('Video Url'), 'label' => __('Video Url'), 'name' => 'video']);
$dateFormat = $this->_localeDate->getDateFormat(\IntlDateFormatter::SHORT);
$timeFormat = $this->_localeDate->getTimeFormat(\IntlDateFormatter::SHORT);
$style = 'color: #000;background-color: #fff; font-weight: bold; font-size: 13px;';
$fieldset->addField('start_time', 'date', ['name' => 'start_time', 'label' => __('Starting time'), 'title' => __('Starting time'), 'required' => true, 'readonly' => true, 'style' => $style, 'class' => 'required-entry', 'date_format' => $dateFormat, 'time_format' => $timeFormat, 'note' => $this->_localeDate->getDateTimeFormat(\IntlDateFormatter::SHORT)]);
$fieldset->addField('end_time', 'date', ['name' => 'end_time', 'label' => __('Ending time'), 'title' => __('Ending time'), 'required' => true, 'readonly' => true, 'style' => $style, 'class' => 'required-entry', 'date_format' => $dateFormat, 'time_format' => $timeFormat, 'note' => $this->_localeDate->getDateTimeFormat(\IntlDateFormatter::SHORT)]);
$fieldset->addField('order_banner', 'text', ['name' => 'order_banner', 'label' => __('Banner Order'), 'title' => __('Banner Order'), 'required' => true]);
$form->setValues($model->getData());
$this->setForm($form);
$this->setChild('form_after', $this->getLayout()->createBlock('Magento\\Backend\\Block\\Widget\\Form\\Element\\Dependence')->addFieldMap($type->getHtmlId(), $type->getName())->addFieldMap($imageField->getHtmlId(), $imageField->getName())->addFieldMap($imageAltText->getHtmlId(), $imageAltText->getName())->addFieldMap($imageUrl->getHtmlId(), $imageUrl->getName())->addFieldMap($imageTarget->getHtmlId(), $imageTarget->getName())->addFieldMap($videoUrl->getHtmlId(), $videoUrl->getName())->addFieldDependence($imageField->getName(), $type->getName(), '1')->addFieldDependence($imageAltText->getName(), $type->getName(), '1')->addFieldDependence($imageUrl->getName(), $type->getName(), '1')->addFieldDependence($imageTarget->getName(), $type->getName(), '1')->addFieldDependence($videoUrl->getName(), $type->getName(), '0'));
return parent::_prepareForm();
}
示例10: _prepareForm
/**
* Prepare form
*
* @return $this
*/
protected function _prepareForm()
{
/* @var $model \Magento\Cms\Model\Page */
$model = $this->_coreRegistry->registry('news');
/*
* Checking if user have permissions to save information
*/
if ($this->_isAllowedAction('Magentostudy_News::save')) {
$isElementDisabled = false;
} else {
$isElementDisabled = true;
}
/** @var \Magento\Framework\Data\Form $form */
$form = $this->_formFactory->create();
$form->setHtmlIdPrefix('news_main_');
$fieldset = $form->addFieldset('base_fieldset', ['legend' => __('News Information')]);
if ($model->getId()) {
$fieldset->addField('news_id', 'hidden', ['name' => 'news_id']);
}
$fieldset->addField('title', 'text', ['name' => 'title', 'label' => __('News Title'), 'title' => __('News Title'), 'required' => true, 'disabled' => $isElementDisabled]);
$fieldset->addField('author', 'text', ['name' => 'author', 'label' => __('Author'), 'title' => __('Author'), 'required' => true, 'disabled' => $isElementDisabled]);
$dateFormat = $this->_localeDate->getDateFormat(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_SHORT);
$fieldset->addField('published_at', 'date', ['name' => 'published_at', 'date_format' => $dateFormat, 'image' => $this->getViewFileUrl('images/grid-cal.gif'), 'value' => $model->getPublishedAt(), 'label' => __('Publishing Date'), 'title' => __('Publishing Date'), 'required' => true]);
$this->_eventManager->dispatch('adminhtml_news_edit_tab_main_prepare_form', ['form' => $form]);
$form->setValues($model->getData());
$this->setForm($form);
return parent::_prepareForm();
}
示例11: _prepareForm
/**
* Prepare form before rendering HTML
*
* @return $this
* @SuppressWarnings(PHPMD.NPathComplexity)
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
protected function _prepareForm()
{
$model = $this->getModel();
$identity = $this->_scopeConfig->getValue(\Magento\Newsletter\Model\Subscriber::XML_PATH_UNSUBSCRIBE_EMAIL_IDENTITY, \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
$identityName = $this->_scopeConfig->getValue('trans_email/ident_' . $identity . '/name', \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
$identityEmail = $this->_scopeConfig->getValue('trans_email/ident_' . $identity . '/email', \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
/** @var \Magento\Framework\Data\Form $form */
$form = $this->_formFactory->create(['data' => ['id' => 'edit_form', 'action' => $this->getData('action'), 'method' => 'post']]);
$fieldset = $form->addFieldset('base_fieldset', ['legend' => __('Template Information'), 'class' => 'fieldset-wide']);
if ($model->getId()) {
$fieldset->addField('id', 'hidden', ['name' => 'id', 'value' => $model->getId()]);
}
$fieldset->addField('code', 'text', ['name' => 'code', 'label' => __('Template Name'), 'title' => __('Template Name'), 'required' => true, 'value' => $model->getTemplateCode()]);
$fieldset->addField('subject', 'text', ['name' => 'subject', 'label' => __('Template Subject'), 'title' => __('Template Subject'), 'required' => true, 'value' => $model->getTemplateSubject()]);
$fieldset->addField('sender_name', 'text', ['name' => 'sender_name', 'label' => __('Sender Name'), 'title' => __('Sender Name'), 'required' => true, 'value' => $model->getId() !== null ? $model->getTemplateSenderName() : $identityName]);
$fieldset->addField('sender_email', 'text', ['name' => 'sender_email', 'label' => __('Sender Email'), 'title' => __('Sender Email'), 'class' => 'validate-email', 'required' => true, 'value' => $model->getId() !== null ? $model->getTemplateSenderEmail() : $identityEmail]);
$widgetFilters = ['is_email_compatible' => 1];
$wysiwygConfig = $this->_wysiwygConfig->getConfig(['widget_filters' => $widgetFilters]);
if ($model->isPlain()) {
$wysiwygConfig->setEnabled(false);
}
$fieldset->addField('text', 'editor', ['name' => 'text', 'label' => __('Template Content'), 'title' => __('Template Content'), 'required' => true, 'state' => 'html', 'style' => 'height:36em;', 'value' => $model->getTemplateText(), 'config' => $wysiwygConfig]);
if (!$model->isPlain()) {
$fieldset->addField('template_styles', 'textarea', ['name' => 'styles', 'label' => __('Template Styles'), 'container_id' => 'field_template_styles', 'value' => $model->getTemplateStyles()]);
}
$form->setAction($this->getUrl('*/*/save'));
$form->setUseContainer(true);
$this->setForm($form);
return parent::_prepareForm();
}
示例12: _prepareForm
/**
* Prepare form
*
* @return $this
*/
protected function _prepareForm()
{
/** @var \Fc\Faqs\Model\Faq $model */
$model = $this->_coreRegistry->registry('faqs_faq');
/** @var \Magento\Framework\Data\Form $form */
/**
* @todo check how method works maybe it should be faq most likely just method type
*/
$form = $this->_formFactory->create(['data' => ['id' => 'edit_form', 'action' => $this->getData('action'), 'method' => 'post']]);
$form->setHtmlIdPrefix('faq_');
$fieldset = $form->addFieldset('base_fieldset', ['legend' => __('General Information'), 'class' => 'fieldset-wide']);
if ($model->getFaqId()) {
$fieldset->addField('faq_id', 'hidden', ['name' => 'faq_id']);
}
$fieldset->addField('title', 'text', ['name' => 'title', 'label' => __('Faq Title'), 'title' => __('Faq Title'), 'required' => true]);
$fieldset->addField('faq_identifier', 'text', ['name' => 'faq_identifier', 'label' => __('Faq Identifier'), 'title' => __('Faq Identifier'), 'required' => true, 'class' => 'validate-xml-identifier']);
$fieldset->addField('is_active', 'select', ['label' => __('Status'), 'title' => __('Status'), 'name' => 'is_active', 'required' => true, 'options' => ['1' => __('Enabled'), '0' => __('Disabled')]]);
/**
* @todo validate as int
*/
$fieldset->addField('sort_order', 'text', ['label' => __('Sort Order'), 'title' => __('Sort Order'), 'name' => 'sort_order', 'required' => true]);
if (!$model->getId()) {
$model->setData('is_active', '1');
}
$fieldset->addField('content', 'editor', ['name' => 'content', 'label' => __('Content'), 'title' => __('Content'), 'style' => 'height:36em', 'required' => true]);
$form->setValues($model->getData());
$form->setUseContainer(true);
$this->setForm($form);
return parent::_prepareForm();
}
示例13: _prepareForm
/**
* Prepare form
*
* @return $this
*/
protected function _prepareForm()
{
/** @var \Test\Testimonials\Model\Post $model */
$model = $this->_coreRegistry->registry('testimonials_post');
/** @var \Magento\Framework\Data\Form $form */
$form = $this->_formFactory->create(['data' => ['id' => 'edit_form', 'action' => $this->getData('action'), 'method' => 'post', 'enctype' => "multipart/form-data"]]);
$form->setHtmlIdPrefix('post_');
$fieldset = $form->addFieldset('base_fieldset', ['legend' => __('General'), 'class' => 'fieldset-wide']);
if ($model->getPostId()) {
$fieldset->addField('post_id', 'hidden', ['name' => 'post_id']);
}
$fieldset->addField('name', 'text', ['name' => 'name', 'label' => __('Name'), 'title' => __('Name'), 'required' => true]);
$fieldset->addField('photo', 'image', ['title' => __('Photo'), 'label' => __('Photo'), 'name' => 'photo_url', 'note' => 'Allow image type: jpg, jpeg, gif, png']);
// $form = $this->_formFactory->create(['data' =>
// ['id' =>
// 'edit_form', 'action' =>
// $this->getData('action'), 'method' => 'post', 'enctype' => 'multipart/form-data']]);
// 'url_key', 'text', [
// 'name' => 'url_key',
// 'label' => __('URL Key'),
// 'title' => __('URL Key'),
// 'required' => true,
// 'class' => 'validate-xml-identifier'
// ]
// );
$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('text', 'editor', ['name' => 'text', 'label' => __('Text'), 'title' => __('text'), 'style' => 'height:36em', 'required' => true]);
$form->setValues($model->getData());
$form->setUseContainer(true);
$this->setForm($form);
return parent::_prepareForm();
}
示例14: _prepareForm
/**
* Prepare form
*
* @return $this
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
protected function _prepareForm()
{
/* @var $model \Emizentech\Banner\Model\BlogPosts */
$model = $this->_coreRegistry->registry('banner');
$isElementDisabled = false;
/** @var \Magento\Framework\Data\Form $form */
$form = $this->_formFactory->create();
$form->setHtmlIdPrefix('page_');
$fieldset = $form->addFieldset('base_fieldset', ['legend' => __('Item Information')]);
if ($model->getId()) {
$fieldset->addField('banner_id', 'hidden', ['name' => 'banner_id']);
}
$fieldset->addField('title', 'text', ['name' => 'title', 'label' => __('Title'), 'title' => __('Title'), 'required' => true, 'disabled' => $isElementDisabled]);
$fieldset->addField('group', 'text', ['name' => 'group', 'label' => __('group'), 'title' => __('Group'), 'required' => false, 'disabled' => $isElementDisabled]);
$fieldset->addField('link', 'text', ['name' => 'link', 'label' => __('Link'), 'title' => __('Link'), 'required' => true, 'disabled' => $isElementDisabled]);
$fieldset->addField('target', 'select', ['label' => __('Target'), 'title' => __('Target'), 'name' => 'target', 'required' => true, 'options' => $this->getTargetOptionArray(), 'disabled' => $isElementDisabled]);
$fieldset->addField('image', 'image', ['name' => 'image', 'label' => __('Image'), 'title' => __('Image'), 'required' => true, 'disabled' => $isElementDisabled]);
$fieldset->addField('is_active', 'select', ['label' => __('Status'), 'title' => __('Status'), 'name' => 'is_active', 'required' => true, 'options' => $this->_status->getOptionArray(), 'disabled' => $isElementDisabled]);
if (!$model->getId()) {
$model->setData('is_active', $isElementDisabled ? '0' : '1');
}
$form->setValues($model->getData());
$this->setForm($form);
return parent::_prepareForm();
}
示例15: _prepareForm
/**
* _prepareForm
*/
protected function _prepareForm()
{
$model = $this->_coreRegistry->registry('current_tandinh_banner_slider');
$form = $this->_formFactory->create();
$form->setHtmlIdPrefix('item_');
$fieldSet = $form->addFieldset('base_fieldset', ['legend' => __('Slider Information')]);
if ($model->getId()) {
$fieldSet->addField('id', 'hidden', ['name' => 'id']);
}
$fieldSet->addField('title', 'text', ['name' => 'title', 'label' => __('Title'), 'title' => __('Title'), 'required' => true]);
$fieldSet->addField('image', 'image', ['name' => 'image', 'label' => __('Image field Label'), 'title' => __('Image field Label')]);
$fieldSet->addField('status', 'select', ['label' => __('Status'), 'title' => __('Status'), 'name' => 'status', 'required' => true, 'options' => ['1' => __('Enabled'), '0' => __('Disabled')]]);
if (!$model->getStatus()) {
$model->setData('status', '1');
}
$options = $this->getBannersOption();
$fieldSet->addField('banner', 'select', ['label' => __('Banner'), 'title' => __('Banner'), 'name' => 'banner', 'required' => true, 'options' => $options]);
if (!$model->getBanner()) {
$model->setData('banner', '1');
}
$fieldSet->addField('url', 'text', ['name' => 'url', 'label' => __('Url'), 'title' => __('Url'), 'required' => true]);
$fieldSet->addField('alt', 'text', ['name' => 'alt', 'label' => __('Alt'), 'title' => __('Alt'), 'required' => false]);
$dateFormat = $this->_localeDate->getDateFormat(\IntlDateFormatter::SHORT);
$fieldSet->addField('start_date', 'date', ['name' => 'start_date', 'label' => __('Start Date'), 'date_format' => $dateFormat, 'title' => __('Start Date'), 'required' => false]);
$fieldSet->addField('end_date', 'date', ['name' => 'end_date', 'label' => __('End Date'), 'title' => __('End Date'), 'date_format' => $dateFormat, 'required' => false, 'class' => 'validate-date validate-date-range date-range-custom_theme-from']);
$form->setValues($model->getData());
$this->setForm($form);
return parent::_prepareForm();
}