2016-09-08 45 views
0

嘿夥計我正在嘗試爲我的網站創建一個簡單的聯繫表單。我正在使用ShaeDawson的模塊模塊。銀條紋:聯繫人表單方法不存在

,我發現了以下錯誤:

"Uncaught Exception: Object->__call(): the method 'contactform' does not exist on 'Block_Controller'"

這裏是我的代碼塊:

<?php 

class ContactBlock extends Block { 
    private static $db = array(
     'ContainToGrid'  => 'Boolean', 
     'SectionBGColour' => 'Varchar', 
     'GridBGColour'  => 'Varchar', 
     'OverrideEmail'  => 'Varchar' 
    ); 

    private static $singular_name = 'Contact Form'; 
    private static $plural_name = 'Contact Forms'; 

    public function getCMSFields() { 
     $fields = parent::getCMSFields(); 

     $fields->addFieldToTab("Root.Main", HeaderField::create('BlockSettings', 'Block settings')->setHeadingLevel(2), "ManyMany[BlockArea]"); 
     $fields->addFieldToTab("Root.Main", CheckBoxField::create("ContainToGrid", "Contain in grid?")); 

     //Background colours of section 
     $fields->addFieldToTab("Root.Main", TextField::create("SectionBGColour", "Block Background Colour") 
      ->setDescription('(Optional) Leave blank for transparent')); 
     $fields->addFieldToTab("Root.Main", TextField::create("GridBGColour", "Grid Background Colour") 
      ->setDescription('(Optional) Leave blank for transparent') 
      ->displayIf('ContainToGrid')->isChecked()->end()); 

     $fields->addFieldToTab("Root.Main", HeaderField::create('EmailNotifications', 'Email Notification')->setHeadingLevel(2)); 

     $fields->addFieldToTab("Root.Main", TextField::create("OverrideEmail", "OverrideEmail") 
      ->setDescription('(Optional) Entering an email address here will override the email set in site settings')); 

     return $fields; 
    } 

    public function ContactForm(){ 
     return $this->getController()->ContactForm(); 
    } 
} 

class ContactForm_Controller extends Block_Controller { 

    private static $allowed_actions = array(
     'ContactForm' 
    ); 

    public function ContactForm(){ 
     $fields = FieldList::create(array(
      TextField::create('Name'), 
      EmailField::create('Email'), 
      TextField::create('Organisation'), 
      TextAreaField::create('Message') 
     )); 
     $actions = FieldList::create(
      FormAction::create('submit', 'Send Enquiry') 
     ); 
     return Form::create($this, 'ContactForm', $fields, $actions); 
    } 
    public function submit($data, $form){ 
     // process form data as usual 
     // ... 
     // redirect 
     return $this->redirect($this->pageLink() . '?contacted=1'); 
    } 

} 

回答

0

解決了這個。菜鳥的錯誤。

我需要從改變我的 '塊控制器' 擴展名:

ContactForm_Controller

到:

ContactBlock_Controller

唉....