2
我得到這個,這不打印驗證錯誤:爲什麼Form-> file()不顯示驗證錯誤?
<?php echo $this->Form->file('fileurl_file', array('label' => '', 'class' => 'input-text')); ?>
如果我將其更改爲
<?php echo $this->Form->input('fileurl_file', array('label' => '', 'class' => 'input-text')); ?>
這表明驗證錯誤。
我做錯了什麼?
Thx!
編輯:
我接過來一看介紹的表單助手類。我發現,即使是有「文件」方法時不中實現不提供,如果逮住任何打印錯誤的支持。
然後,我看到「輸入」方法在某些時候作爲參數「類型」(我猜這也在文檔中提到過,但我沒有閱讀全部內容),它可以來自「文本」 ,「文件」,「選擇」 ...
所以,這就是我設法讓我的文件稱輸入工作,因爲我需要:
<?php echo $this->Form->input('fileurl_file', array('type' => 'file', 'label' => '', 'class' => 'input-text')); ?>
你可以顯示'$ this-> Form-> create'代碼的形式以及你如何在Model中進行驗證? – 2012-03-18 12:14:07
<?php echo $ this-> Form-> create('Meta',array('class'=>'form-default section','method'=>'post','enctype'=>'multipart/form -數據')); ?> – Michael 2012-03-18 12:34:47
這是create(),驗證是在BehaviourModel中完成的,但它並不重要,因爲正如我所說的,工作與非工作(顯示錯誤)之間的區別在於創建文本/文件輸入。 – Michael 2012-03-18 12:37:40