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


PHP Observer::getForm方法代码示例

本文整理汇总了PHP中Magento\Framework\Event\Observer::getForm方法的典型用法代码示例。如果您正苦于以下问题:PHP Observer::getForm方法的具体用法?PHP Observer::getForm怎么用?PHP Observer::getForm使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Magento\Framework\Event\Observer的用法示例。


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

示例1: prepareForm

 /**
  * @param \Magento\Framework\Event\Observer $observer
  * @return void
  */
 public function prepareForm($observer)
 {
     /** @var \Magento\Framework\Data\Form $form */
     $form = $observer->getForm();
     foreach ($form->getElements() as $element) {
         /** @var \Magento\Framework\Data\Form\Element\AbstractElement $element */
         if ($element->getId() == 'action_fieldset') {
             $element->addField('simple_free_shipping', 'select', array('label' => __('Free Shipping'), 'title' => __('Free Shipping'), 'name' => 'simple_free_shipping', 'options' => array(0 => __('No'), Rule::FREE_SHIPPING_ITEM => __('For matching items only'), Rule::FREE_SHIPPING_ADDRESS => __('For shipment with matching items'))));
         }
     }
 }
开发者ID:aiesh,项目名称:magento2,代码行数:15,代码来源:ActionsTab.php

示例2: execute

 /**
  * @param \Magento\Framework\Event\Observer $observer
  * @return void
  */
 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     /** @var \Magento\Framework\Data\Form $form */
     $form = $observer->getForm();
     foreach ($form->getElements() as $element) {
         /** @var \Magento\Framework\Data\Form\Element\AbstractElement $element */
         if ($element->getId() != 'action_fieldset') {
             continue;
         }
         $element->addField('simple_free_shipping', 'select', ['label' => __('Free Shipping'), 'title' => __('Free Shipping'), 'name' => 'simple_free_shipping', 'options' => [0 => __('No'), Rule::FREE_SHIPPING_ITEM => __('For matching items only'), Rule::FREE_SHIPPING_ADDRESS => __('For shipment with matching items')]]);
     }
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:16,代码来源:ActionsTabPrepareFormObserver.php

示例3: execute

 /**
  * @param \Magento\Framework\Event\Observer $observer
  * @return void
  */
 public function execute(EventObserver $observer)
 {
     if (!$this->moduleManager->isOutputEnabled('Magento_Swatches')) {
         return;
     }
     /** @var \Magento\Framework\Data\Form $form */
     $form = $observer->getForm();
     $fieldset = $form->getElement('base_fieldset');
     $yesnoSource = $this->yesNo->toOptionArray();
     $fieldset->addField('update_product_preview_image', 'select', ['name' => 'update_product_preview_image', 'label' => __('Update Product Preview Image'), 'title' => __('Update Product Preview Image'), 'note' => __('Filtering by this attribute will update the product image on catalog page'), 'values' => $yesnoSource], 'is_filterable');
     $fieldset->addField('use_product_image_for_swatch', 'select', ['name' => 'use_product_image_for_swatch', 'label' => __('Use Product Image for Swatch if Possible'), 'title' => __('Use Product Image for Swatch if Possible'), 'note' => __('Allows use fallback logic for replacing swatch image with product swatch or base image'), 'values' => $yesnoSource], 'is_filterable');
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:16,代码来源:AddFieldsToAttributeObserver.php

示例4: execute

 /**
  * @param \Magento\Framework\Event\Observer $observer
  * @return void
  */
 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     if (!$this->moduleManager->isOutputEnabled('Magento_LayeredNavigation')) {
         return;
     }
     /** @var \Magento\Framework\Data\Form\AbstractForm $form */
     $form = $observer->getForm();
     $fieldset = $form->getElement('front_fieldset');
     $fieldset->addField('is_filterable', 'select', ['name' => 'is_filterable', 'label' => __("Use in Layered Navigation"), 'title' => __('Can be used only with catalog input type Dropdown, Multiple Select and Price'), 'note' => __('Can be used only with catalog input type Dropdown, Multiple Select and Price.'), 'values' => [['value' => '0', 'label' => __('No')], ['value' => '1', 'label' => __('Filterable (with results)')], ['value' => '2', 'label' => __('Filterable (no results)')]]]);
     $fieldset->addField('is_filterable_in_search', 'select', ['name' => 'is_filterable_in_search', 'label' => __("Use in Search Results Layered Navigation"), 'title' => __('Can be used only with catalog input type Dropdown, Multiple Select and Price'), 'note' => __('Can be used only with catalog input type Dropdown, Multiple Select and Price.'), 'values' => $this->optionList->toOptionArray()]);
     $fieldset->addField('position', 'text', ['name' => 'position', 'label' => __('Position'), 'title' => __('Position in Layered Navigation'), 'note' => __('Position of attribute in layered navigation block.'), 'class' => 'validate-digits']);
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:16,代码来源:ProductAttributeFormBuildFrontTabObserver.php

示例5: execute

 /**
  * @param \Magento\Framework\Event\Observer $observer
  * @return void
  */
 public function execute(EventObserver $observer)
 {
     if (!$this->isVariationsPopupUsed()) {
         return;
     }
     /** @var \Magento\Framework\Data\Form $form */
     $form = $observer->getForm();
     $filteredValues = [];
     /** @var \Magento\Framework\Data\Form\Element\Select $frontendInput */
     $frontendInput = $form->getElement('frontend_input');
     foreach ($frontendInput->getValues() as $frontendValue) {
         if (in_array($frontendValue['value'], $this->supportedTypes, true)) {
             $filteredValues[] = $frontendValue;
         }
     }
     $frontendInput->setValues($filteredValues);
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:21,代码来源:HideUnsupportedAttributeTypes.php

示例6: addFieldToAttributeEditForm

 public function addFieldToAttributeEditForm(\Magento\Framework\Event\Observer $observer)
 {
     // Add an extra field to the base fieldset:
     $fieldset = $observer->getForm()->getElement('base_fieldset');
     $fieldset->addField('description', 'textarea', ['name' => 'description', 'label' => __('Description'), 'title' => __('Description'), 'style' => 'width: 600px;', 'required' => false]);
 }
开发者ID:shakhawat4g,项目名称:MagentoExtensions,代码行数:6,代码来源:Observer.php


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