当前位置: 首页>>代码示例>>PHP>>正文


PHP Form\Generic类代码示例

本文整理汇总了PHP中Magento\Backend\Block\Widget\Form\Generic的典型用法代码示例。如果您正苦于以下问题:PHP Generic类的具体用法?PHP Generic怎么用?PHP Generic使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Generic类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _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();
 }
开发者ID:TheFrankman,项目名称:magento2-faq,代码行数:35,代码来源:Form.php

示例2: _prepareForm

 protected function _prepareForm()
 {
     $form = $this->_formFactory->create(array('data' => array('id' => 'edit_form', 'action' => $this->getUrl('*/*/save'), 'method' => 'post', 'enctype' => 'multipart/form-data')));
     $form->setUseContainer(true);
     $this->setForm($form);
     return parent::_prepareForm();
 }
开发者ID:mrtuvn,项目名称:m2ce.dev,代码行数:7,代码来源:Form.php

示例3: _prepareForm

 /**
  * Prepare form
  *
  * @return $this
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 protected function _prepareForm()
 {
     $idGroup = $this->getRequest()->getParam('group_id');
     $model = $this->_coreRegistry->registry('layout_elements_form_data');
     /** @var \Magento\Framework\Data\Form $form */
     $form = $this->_formFactory->create();
     $form->setHtmlIdPrefix('page_');
     $fieldset = $form->addFieldset('base_fieldset', ['legend' => __('Element Information')]);
     $fieldset->addType('image', 'OuterEdge\\Layout\\Block\\Adminhtml\\Elements\\Helper\\Image');
     if ($model->getId()) {
         $fieldset->addField('element_id', 'hidden', ['name' => 'element_id']);
         $fieldset->addField('group_id', 'hidden', ['name' => 'group_id']);
     }
     if ($idGroup) {
         $model->setGroupId($idGroup);
         $fieldset->addField('group_id', 'hidden', ['name' => 'group_id']);
     }
     $fieldset->addField('title', 'text', ['name' => 'title', 'label' => __('Title'), 'title' => __('Title'), 'required' => true]);
     $fieldset->addField('description', 'textarea', ['name' => 'description', 'label' => __('Description'), 'title' => __('Description'), 'required' => true]);
     $fieldset->addField('link', 'text', ['name' => 'link', 'label' => __('Link'), 'title' => __('Link'), 'required' => false]);
     $fieldset->addField('link_text', 'text', ['name' => 'link_text', 'label' => __('Link Text'), 'title' => __('Link Text'), 'required' => false]);
     $fieldset->addField('image', 'image', ['name' => 'image', 'label' => __('Image'), 'title' => __('Image'), 'required' => false, 'note' => 'Allow image type: jpg, jpeg, gif, png']);
     $fieldset->addField('sort_order', 'text', ['name' => 'sort_order', 'label' => __('Sort Order'), 'title' => __('Sort Order'), 'required' => false]);
     $form->setValues($model->getData());
     $this->setForm($form);
     return parent::_prepareForm();
 }
开发者ID:outeredge,项目名称:magento-layout-module,代码行数:33,代码来源:Main.php

示例4: _prepareForm

 protected function _prepareForm()
 {
     $form = $this->_formFactory->create(['data' => ['id' => 'edit_form', 'action' => $this->getData('action'), 'method' => 'post', 'enctype' => 'multipart/form-data']]);
     $form->setUseContainer(true);
     $this->setForm($form);
     return parent::_prepareForm();
 }
开发者ID:dragonsword007008,项目名称:magento2,代码行数:7,代码来源:Form.php

示例5: _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();
 }
开发者ID:vishalktpl,项目名称:CHAT,代码行数:30,代码来源:Content.php

示例6: __construct

 /**
  * @param \Magento\Backend\Block\Template\Context $context
  * @param \Magento\Framework\Json\EncoderInterface $jsonEncoder
  * @param \Magento\Framework\Registry $registry
  * @param \Magento\Framework\Data\FormFactory $formFactory
  * @param \Magento\Catalog\Model\CategoryFactory $categoryFactory
  * @param array $data
  */
 public function __construct(\Magento\Backend\Block\Template\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\Data\FormFactory $formFactory, \Magento\Framework\Json\EncoderInterface $jsonEncoder, \Magento\Catalog\Model\CategoryFactory $categoryFactory, array $data = array())
 {
     $this->_jsonEncoder = $jsonEncoder;
     $this->_categoryFactory = $categoryFactory;
     parent::__construct($context, $registry, $formFactory, $data);
     $this->setUseContainer(true);
 }
开发者ID:Atlis,项目名称:docker-magento2,代码行数:15,代码来源:NewCategory.php

示例7: _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();
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:36,代码来源:Form.php

示例8: _prepareForm

 /**
  * Initialise form fields
  *
  * @return $this
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 protected function _prepareForm()
 {
     /*
      * Checking if user have permissions to save information
      */
     $isElementDisabled = !$this->_isAllowedAction('Magento_Cms::save');
     /** @var \Magento\Framework\Data\Form $form */
     $form = $this->_formFactory->create(['data' => ['html_id_prefix' => 'page_']]);
     $model = $this->_coreRegistry->registry('cms_page');
     $layoutFieldset = $form->addFieldset('layout_fieldset', ['legend' => __('Page Layout'), 'class' => 'fieldset-wide', 'disabled' => $isElementDisabled]);
     $layoutFieldset->addField('page_layout', 'select', ['name' => 'page_layout', 'label' => __('Layout'), 'required' => true, 'values' => $this->pageLayoutBuilder->getPageLayoutsConfig()->toOptionArray(), 'disabled' => $isElementDisabled]);
     if (!$model->getId()) {
         $model->setRootTemplate($this->_pageLayout->getDefaultValue());
     }
     $layoutFieldset->addField('layout_update_xml', 'textarea', ['name' => 'layout_update_xml', 'label' => __('Layout Update XML'), 'style' => 'height:24em;', 'disabled' => $isElementDisabled]);
     $designFieldset = $form->addFieldset('design_fieldset', ['legend' => __('Custom Design'), 'class' => 'fieldset-wide', 'disabled' => $isElementDisabled]);
     $dateFormat = $this->_localeDate->getDateFormat(\IntlDateFormatter::SHORT);
     $designFieldset->addField('custom_theme_from', 'date', ['name' => 'custom_theme_from', 'label' => __('Custom Design From'), 'date_format' => $dateFormat, 'disabled' => $isElementDisabled, 'class' => 'validate-date validate-date-range date-range-custom_theme-from']);
     $designFieldset->addField('custom_theme_to', 'date', ['name' => 'custom_theme_to', 'label' => __('Custom Design To'), 'date_format' => $dateFormat, 'disabled' => $isElementDisabled, 'class' => 'validate-date validate-date-range date-range-custom_theme-to']);
     $options = $this->_labelFactory->create()->getLabelsCollection(__('-- Please Select --'));
     $designFieldset->addField('custom_theme', 'select', ['name' => 'custom_theme', 'label' => __('Custom Theme'), 'values' => $options, 'disabled' => $isElementDisabled]);
     $designFieldset->addField('custom_page_layout', 'select', ['name' => 'custom_page_layout', 'label' => __('Custom Layout'), 'values' => $this->pageLayoutBuilder->getPageLayoutsConfig()->toOptionArray(true), 'disabled' => $isElementDisabled]);
     $designFieldset->addField('custom_layout_update_xml', 'textarea', ['name' => 'custom_layout_update_xml', 'label' => __('Custom Layout Update XML'), 'style' => 'height:24em;', 'disabled' => $isElementDisabled]);
     $this->_eventManager->dispatch('adminhtml_cms_page_edit_tab_design_prepare_form', ['form' => $form]);
     $form->setValues($model->getData());
     $this->setForm($form);
     return parent::_prepareForm();
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:34,代码来源:Design.php

示例9: _prepareForm

 /**
  * Prepare form fields
  *
  * @return \Magento\Backend\Block\Widget\Form
  */
 protected function _prepareForm()
 {
     $form = $this->_formFactory->create();
     $form->setHtmlIdPrefix('manufacturer_');
     $form->setFieldNameSuffix('manufacturer');
     $model = $this->_coreRegistry->registry('manufacturer_manufacturer');
     $om = \Magento\Framework\App\ObjectManager::getInstance();
     $reader = $om->get('Magento\\Eav\\Model\\Config')->getAttribute('catalog_product', 'manufacturer');
     $attributeOptions = $reader->getSource()->getAllOptions(true, true);
     $default = array('value' => '', 'label' => 'Choose Brand');
     $i = 0;
     $manufacturer[$i] = $default;
     foreach ($attributeOptions as $key => $value) {
         $i++;
         if ($key != 0) {
             $manufacturer[$i] = $value;
             //$name[$i] = $value['label'];
         }
     }
     $fieldset = $form->addFieldset('base_fieldset', ['legend' => __('General')]);
     if ($model->getId()) {
         $fieldset->addField('id', 'hidden', ['name' => 'id']);
     }
     $fieldset->addField('mfc_id', 'select', ['name' => 'mfc_id', 'label' => __('Manufacturer'), 'required' => true, 'values' => $manufacturer]);
     $fieldset->addField('status', 'select', ['name' => 'status', 'label' => __('Status'), 'options' => $this->_manufacturerStatus->toOptionArray()]);
     $fieldset->addField('position', 'textarea', ['name' => 'position', 'label' => __('Position'), 'required' => true, 'style' => 'height: 15em; width: 30em;']);
     $fieldset->addField('image_path', 'image', array('name' => 'image_path', 'label' => __('Image'), 'title' => __('Image')));
     $wysiwygConfig = $this->_wysiwygConfig->getConfig();
     $fieldset->addField('description', 'editor', ['name' => 'description', 'label' => __('Description'), 'required' => true, 'config' => $wysiwygConfig]);
     $data = $model->getData();
     $form->setValues($data);
     $this->setForm($form);
     return parent::_prepareForm();
 }
开发者ID:rushvisilk,项目名称:mage2-helloworld,代码行数:39,代码来源:Info.php

示例10: _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();
 }
开发者ID:igor-lero9,项目名称:magebase_carousel,代码行数:35,代码来源:Banner.php

示例11: _prepareForm

 /**
  * Prepare form
  *
  * @return $this
  */
 protected function _prepareForm()
 {
     /** @var $model \Ves\Brand\Model\Brand */
     $model = $this->_coreRegistry->registry('ves_brand');
     /**
      * Checking if user have permission to save information
      */
     if ($this->_isAllowedAction('Ves_Brand::group_edit')) {
         $isElementDisabled = false;
     } else {
         $isElementDisabled = true;
     }
     /** @var \Magento\Framework\Data\Form $form */
     $form = $this->_formFactory->create();
     $form->setHtmlIdPrefix('brand_');
     $fieldset = $form->addFieldset('base_fieldset', ['legend' => __('Group Information')]);
     if ($model->getId()) {
         $fieldset->addField('group_id', 'hidden', ['name' => 'group_id']);
     }
     $fieldset->addField('name', 'text', ['name' => 'name', 'label' => __('Group Name'), 'title' => __('Group Name'), 'required' => true, 'disabled' => $isElementDisabled]);
     $fieldset->addField('url_key', 'text', ['name' => 'url_key', 'label' => __('URL Key'), 'title' => __('URL Key'), 'note' => __('Empty to auto create url key'), 'disabled' => $isElementDisabled]);
     $fieldset->addField('position', 'text', ['name' => 'position', 'label' => __('Position'), 'title' => __('Position'), 'disabled' => $isElementDisabled]);
     $fieldset->addField('status', 'select', ['label' => __('Status'), 'title' => __('Page Status'), 'name' => 'status', 'options' => $model->getAvailableStatuses(), 'disabled' => $isElementDisabled]);
     $fieldset->addField('shown_in_sidebar', 'select', ['label' => __('Show In Sidebar'), 'title' => __('Show In Sidebar'), 'name' => 'shown_in_sidebar', 'options' => $model->getAvailableStatuses(), 'disabled' => $isElementDisabled]);
     $form->setValues($model->getData());
     $this->setForm($form);
     return parent::_prepareForm();
 }
开发者ID:vasuscoin,项目名称:brand,代码行数:33,代码来源:Main.php

示例12: _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();
 }
开发者ID:ktplKunj,项目名称:TestMagento,代码行数:32,代码来源:Testimonial.php

示例13: _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();
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:37,代码来源:Form.php

示例14: _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();
 }
开发者ID:dineshmalekar,项目名称:magento2-extension-example,代码行数:33,代码来源:Main.php

示例15: __construct

 /**
  * @param \Magento\Backend\Block\Template\Context $context
  * @param \Magento\Framework\Registry $registry
  * @param \Magento\Framework\Data\FormFactory $formFactory
  * @param \Magento\Newsletter\Model\QueueFactory $queueFactory
  * @param \Magento\Store\Model\System\Store $systemStore
  * @param \Magento\Cms\Model\Wysiwyg\Config $wysiwygConfig
  * @param array $data
  */
 public function __construct(\Magento\Backend\Block\Template\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\Data\FormFactory $formFactory, \Magento\Newsletter\Model\QueueFactory $queueFactory, \Magento\Store\Model\System\Store $systemStore, \Magento\Cms\Model\Wysiwyg\Config $wysiwygConfig, array $data = [])
 {
     $this->_wysiwygConfig = $wysiwygConfig;
     $this->_systemStore = $systemStore;
     $this->_queueFactory = $queueFactory;
     parent::__construct($context, $registry, $formFactory, $data);
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:16,代码来源:Form.php


注:本文中的Magento\Backend\Block\Widget\Form\Generic类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。