簡體   English   中英

Zend形式:調用未定義的方法Zend \\ InputFilter \\ InputFilter :: getFilterChain()

[英]Zend Form : Call to undefined method Zend\InputFilter\InputFilter::getFilterChain()

我正在嘗試使用Zend Form上傳圖像。 當我們需要它來移動圖像時,我想添加一個過濾器來完成這項工作。 但是我不能使用getInputFilterChain(),但我仍然遇到這個致命錯誤: Call to undefined method Zend\\InputFilter\\InputFilter::getFilterChain() 我在這里想念什么?

我可以在$ prg數組中獲取文件信息。 正如我在https://framework.zend.com/manual/2.4/en/modules/zend.mvc.plugins.html上看到的那樣,該方法應該在這里存在,不是嗎?

如果在Form.php文件中使用此錯誤,也會收到相同的錯誤。

預先感謝您的寶貴時間!

我的控制器動作:

public function signinAction()
{
    $this->em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default');

    $form = new SignupForm($this->em);

    $form->getInputFilter()->getFilterChain()->attach(
        new Zend\Filter\File\RenameUpload(array(
            'target'    => './data/tmpuploads/file',
            'randomize' => true,
        ))
    );

    $model = new ViewModel(array("form" => $form));


    $url = $this->url()->fromRoute("signin");
    $prg = $this->fileprg($form, $url, true);

    if($prg instanceof \Zend\Http\PhpEnvironment\Response){       
        return $prg;
    }
    else if($prg === false){
       return $model;
    }

    //other stuff
    ...
}

您需要首先從InputFilter獲取Input實例,然后才能從輸入獲取filter-chain:

$inputName = 'file'; // name of the input you want to work with
$input = $form->getInputFilter()->get($inputName);
$filterChain = $input->getFilterChain();

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM