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


PHP Form::setAction方法代码示例

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


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

示例1: _formPostInit

 /**
  * Form post init
  *
  * @param \Magento\Framework\Data\Form $form
  * @return $this
  */
 protected function _formPostInit($form)
 {
     $form->setAction($this->_adminhtmlData->getUrl('adminhtml/*/save', array('id' => $this->_getModel()->getId(), 'product' => $this->_getProduct()->getId(), 'category' => $this->_getCategory()->getId())));
     /** @var $requestPath \Magento\Framework\Data\Form\Element\AbstractElement */
     $requestPath = $this->getForm()->getElement('request_path');
     /** @var $targetPath \Magento\Framework\Data\Form\Element\AbstractElement */
     $targetPath = $this->getForm()->getElement('target_path');
     $model = $this->_getModel();
     $disablePaths = false;
     if (!$model->getId()) {
         $product = null;
         $category = null;
         if ($this->_getProduct()->getId()) {
             $product = $this->_getProduct();
             $category = $this->_getCategory();
         } elseif ($this->_getCategory()->getId()) {
             $category = $this->_getCategory();
         }
         if ($product || $category) {
             $sessionData = $this->_getSessionData();
             if (!isset($sessionData['request_path'])) {
                 $requestPath->setValue($this->_catalogUrl->generatePath('request', $product, $category, ''));
             }
             $targetPath->setValue($this->_catalogUrl->generatePath('target', $product, $category));
             $disablePaths = true;
         }
     } else {
         $disablePaths = in_array($model->getEntityType(), [UrlRedirect::ENTITY_TYPE_PRODUCT, UrlRedirect::ENTITY_TYPE_CATEGORY, UrlRedirect::ENTITY_TYPE_CMS_PAGE]);
     }
     if ($disablePaths) {
         $targetPath->setData('disabled', true);
     }
     return $this;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:40,代码来源:Form.php

示例2: _formPostInit

 /**
  * Form post init
  *
  * @param \Magento\Framework\Data\Form $form
  * @return \Magento\UrlRedirect\Block\Cms\Page\Edit\Form
  */
 protected function _formPostInit($form)
 {
     $cmsPage = $this->_getCmsPage();
     $form->setAction($this->_adminhtmlData->getUrl('adminhtml/*/save', array('id' => $this->_getModel()->getId(), 'cms_page' => $cmsPage->getId())));
     // Fill request path and target path elements
     /** @var $requestPath \Magento\Framework\Data\Form\Element\AbstractElement */
     $requestPath = $this->getForm()->getElement('request_path');
     /** @var $targetPath \Magento\Framework\Data\Form\Element\AbstractElement */
     $targetPath = $this->getForm()->getElement('target_path');
     $model = $this->_getModel();
     /** @var $cmsPageUrlrewrite \Magento\Cms\Model\Page\Urlrewrite */
     $cmsPageUrlrewrite = $this->_urlRewriteFactory->create();
     if (!$model->getId()) {
         $sessionData = $this->_getSessionData();
         if (!isset($sessionData['request_path'])) {
             $requestPath->setValue($cmsPageUrlrewrite->generateRequestPath($cmsPage));
         }
         $targetPath->setValue($cmsPageUrlrewrite->generateTargetPath($cmsPage));
         $disablePaths = true;
     } else {
         $cmsPageUrlrewrite->load($this->_getModel()->getId(), 'url_rewrite_id');
         $disablePaths = $cmsPageUrlrewrite->getId() > 0;
     }
     if ($disablePaths) {
         $targetPath->setData('disabled', true);
     }
     return $this;
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:34,代码来源:Form.php

示例3: _formPostInit

 /**
  * Form post init
  *
  * @param \Magento\Framework\Data\Form $form
  * @return \Magento\UrlRewrite\Block\Cms\Page\Edit\Form
  */
 protected function _formPostInit($form)
 {
     $cmsPage = $this->_getCmsPage();
     $form->setAction($this->_adminhtmlData->getUrl('adminhtml/*/save', ['id' => $this->_getModel()->getId(), 'cms_page' => $cmsPage->getId()]));
     // Fill request path and target path elements
     /** @var $requestPath \Magento\Framework\Data\Form\Element\AbstractElement */
     $requestPath = $this->getForm()->getElement('request_path');
     /** @var $targetPath \Magento\Framework\Data\Form\Element\AbstractElement */
     $targetPath = $this->getForm()->getElement('target_path');
     $model = $this->_getModel();
     if (!$model->getId()) {
         $sessionData = $this->_getSessionData();
         if (!isset($sessionData['request_path'])) {
             $requestPath->setValue($this->cmsPageUrlPathGenerator->getUrlPath($cmsPage));
         }
         $targetPath->setValue($this->cmsPageUrlPathGenerator->getCanonicalUrlPath($cmsPage));
     }
     $targetPath->setData('disabled', true);
     return $this;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:26,代码来源:Form.php

示例4: _formPostInit

 /**
  * Form post init
  *
  * @param \Magento\Framework\Data\Form $form
  * @return $this
  */
 protected function _formPostInit($form)
 {
     $form->setAction($this->_adminhtmlData->getUrl('adminhtml/*/save', ['id' => $this->_getModel()->getId()]));
     return $this;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:11,代码来源:Form.php

示例5: _formPostInit

 /**
  * Form post init
  *
  * @param \Magento\Framework\Data\Form $form
  * @return \Magento\Backend\Block\Urlrewrite\Catalog\Edit\Form
  */
 protected function _formPostInit($form)
 {
     // Set form action
     $form->setAction($this->_adminhtmlData->getUrl('adminhtml/*/save', array('id' => $this->_getModel()->getId(), 'product' => $this->_getProduct()->getId(), 'category' => $this->_getCategory()->getId())));
     // Fill id path, request path and target path elements
     /** @var $idPath \Magento\Framework\Data\Form\Element\AbstractElement */
     $idPath = $this->getForm()->getElement('id_path');
     /** @var $requestPath \Magento\Framework\Data\Form\Element\AbstractElement */
     $requestPath = $this->getForm()->getElement('request_path');
     /** @var $targetPath \Magento\Framework\Data\Form\Element\AbstractElement */
     $targetPath = $this->getForm()->getElement('target_path');
     $model = $this->_getModel();
     $disablePaths = false;
     if (!$model->getId()) {
         $product = null;
         $category = null;
         if ($this->_getProduct()->getId()) {
             $product = $this->_getProduct();
             $category = $this->_getCategory();
         } elseif ($this->_getCategory()->getId()) {
             $category = $this->_getCategory();
         }
         if ($product || $category) {
             $idPath->setValue($this->_catalogUrl->generatePath('id', $product, $category));
             $sessionData = $this->_getSessionData();
             if (!isset($sessionData['request_path'])) {
                 $requestPath->setValue($this->_catalogUrl->generatePath('request', $product, $category, ''));
             }
             $targetPath->setValue($this->_catalogUrl->generatePath('target', $product, $category));
             $disablePaths = true;
         }
     } else {
         $disablePaths = $model->getProductId() || $model->getCategoryId();
     }
     // Disable id_path and target_path elements
     if ($disablePaths) {
         $idPath->setData('disabled', true);
         $targetPath->setData('disabled', true);
     }
     return $this;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:47,代码来源:Form.php


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