在我的代碼,我有這樣的事情:如何將標籤添加到「文件上傳」輸入?
echo $this->Form->input('name');
echo $this->Form->input('app_code');
echo $this->Form->file('icon');
echo $this->Form->input('description');
而且形式如下:
正如你可以看到,文件輸入沒有像其他標籤輸入文本字段。我如何添加一個(而不必手動創建HTML)?
在我的代碼,我有這樣的事情:如何將標籤添加到「文件上傳」輸入?
echo $this->Form->input('name');
echo $this->Form->input('app_code');
echo $this->Form->file('icon');
echo $this->Form->input('description');
而且形式如下:
正如你可以看到,文件輸入沒有像其他標籤輸入文本字段。我如何添加一個(而不必手動創建HTML)?
$this->Form->input('icon', array('label' => 'Your label', 'type' => 'file'));
您可以使用各種類型的$this->Form->input
。它默認爲文字輸入,但會做更多。
echo $this->Form->input('icon', array('type' => 'file'));
在食譜中有more information。
看看這裏的API http://api13.cakephp.org/class/form-helper#method-FormHelperinput勢必會在未來有所幫助。
您是如何爲其他輸入添加標籤的? –
標籤是通過'input'方法自動添加的。 – Cristian