當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。