本文整理汇总了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'))));
}
}
}
示例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')]]);
}
}
示例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');
}
示例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']);
}
示例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);
}
示例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]);
}