2014-10-12 63 views
1

我已经使用下面的代码创建了一个表单。如何删除或更改CakePHP中输入字段的标签?

<?php $this->Form->create('Course'); ?> 

格式的文本元素是由以下与标签显示...

<?php $this->Form->input('code'); ?> 

但我不希望显示的文本字段的标签。
在上面的编码中应该做些什么改变?

回答

5

如果要更改标签,使用此。

$this->Form->input('code', array('label' => 'LabelName')); 
1

$this->Form->input('code', array('label' => false));

或者,如果你想将标签更改为其他你所选择的东西:

$this->Form->input('code', array('label' => 'something else'));

2

,如果你想删除的标签,你需要使用:

<?php echo $this->Form->input('code', array('label' => false)); ?> 

对于输入的标签的完全控制,最好的办法就是用这样的:

<?php echo $this->Form->input('code',array('label'=>array('text'=>'This is my label','class'=>' this is the class of my label'))); ?>