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