2017-07-09 20 views
0

我有TYPO3 7.6.18和我有問題,我的addCommentAction不起作用/不被調用。TYPO3行動不叫

\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin(
    "MyVendor.".$_EXTKEY, 
    'commentForm', 
    'Comment form' 
); 

\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
    'MyVendor.'.$_EXTKEY, 
    'commentForm', 
    array('Comment' => 'form,addComment'), 
    array('Comment' => 'form,addComment') 
); 



<f:form action="addComment" object="{newComment}" name="newComment" method="post" additionalParams="{showUid: userto}"> 
     <div style="overflow: hidden;"> 
      <div id="reviewStars-input"> 
       <f:form.hidden property="userto" value="{userto}"/> 
       <f:form.radio property="rating" value="5" id="star-4"/> 
       <label title="{f:translate(key: 'tx_fecomments_domain_model_comment.gorgeous')}" for="star-4"></label> 
       <f:form.radio property="rating" value="4" id="star-3"/> 
       <label title="{f:translate(key: 'tx_fecomments_domain_model_comment.good')}" for="star-3"></label> 
       <f:form.radio property="rating" value="3" id="star-2"/> 
       <label title="{f:translate(key: 'tx_fecomments_domain_model_comment.regular')}" for="star-2"></label> 
       <f:form.radio property="rating" value="2" id="star-1"/> 
       <label title="{f:translate(key: 'tx_fecomments_domain_model_comment.poor')}" for="star-1"></label> 
       <f:form.radio property="rating" value="1" id="star-0"/> 
       <label title="{f:translate(key: 'tx_fecomments_domain_model_comment.bad')}" for="star-0"></label> 
      </div> 
     </div> 
     <div> 
      <f:form.textfield style="height: 100px;" property="text"/> 
      <br> 
      <f:form.submit class="btn btn-primary" value="{f:translate(key: 'tx_fecomments_domain_model_comment.send_comment')}"/> 
     </div> 

    </f:form> 


    /** 
    * @param \MyVendor\Fecomments\Domain\Model\Comment $newComment 
    * @return bool 
    */ 
    public function addCommentAction(\MyVendor\Fecomments\Domain\Model\Comment $newComment) 
    { 
     die(8979); 
} 

當我點擊「發送表單」時,沒有任何反應。我不知道爲什麼。似乎addComment行動不會被調用。在我的其他擴展中,類似的代碼正常工作當我點擊「發送表格」我有下一個網址site.en/?showUid=1&tx_fecomments_commentform%5Baction%5D=addComment&tx_fecomments_commentform%5Bcontroller%5D=Comment&cHash=236d87f2ee987ddf7b5720ae5ddc029e

它必須工作,所以我不知道它爲什麼不起作用。請幫助我,我真的沒有任何想法。

而且這是我的評價模型:

namespace MyVendor\Fecomments\Domain\Model; 

use TYPO3\CMS\Extbase\DomainObject\AbstractEntity; 

class Comment extends AbstractEntity { 
    /** 
    * @var string 
    **/ 
    protected $text = ''; 

    /** 
    * user 
    * 
    * @var \Fhk\Feusersplus\Domain\Model\User 
    */ 
    protected $userfrom; 

    /** 
    * user 
    * 
    * @var \Fhk\Feusersplus\Domain\Model\User 
    */ 
    protected $userto; 

    /** 
    * @var int 
    **/ 
    protected $crdate; 

    /** 
    * @var int 
    **/ 
    protected $rating; 

    /** 
    * @param int $userfrom 
    */ 
    public function setUserfrom($userfrom) { 
     $this->userfrom = (int)$userfrom; 
    } 

    /** 
    * @return \Fhk\Feusersplus\Domain\Model\User 
    */ 
    public function getUserfrom() { 
     return $this->userfrom; 
    } 

    /** 
    * @param int $userto 
    */ 
    public function setUserto($userto) { 
     $this->userto = (int)$userto; 
    } 

    /** 
    * @return \Fhk\Feusersplus\Domain\Model\User 
    */ 
    public function getUserto() { 
     return $this->userto; 
    } 

    /** 
    * @param int $crdate 
    */ 
    public function setCrdate($crdate) { 
     $this->userto = (int)$crdate; 
    } 

    /** 
    * @param int $rating 
    */ 
    public function setRating($rating) { 
     $this->rating = (int)$rating; 
    } 

    /** 
    * @return int 
    */ 
    public function getCrdate() { 
     return $this->crdate; 
    } 

    /** 
    * @return int 
    */ 
    public function getRating() { 
     return $this->rating; 
    } 

    /** 
    * @param $text 
    */ 
    public function setText($text) { 
     $this->text = (string)$text; 
    } 

    /** 
    * @return string 
    */ 
    public function getText() { 
     return $this->text; 
    } 
} 
+0

請添加您的域模型的另一個片段。由於驗證問題,可能表單提交失敗。 – derhansen

+0

我在模型中添加了片段。我希望能爲你提供幫助。真的,我沒有任何想法,爲什麼它不起作用 – Mikael

回答

0

我解決我的問題。我的TCA沒有定義「評分」字段。