Optimus Prime
Optimus Prime

Reputation: 308

How to remove or change the label of input field in CakePHP?

I have created a form by using the below code.

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

Form text element is displaying with label by the following...

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

But i don't want to show the label of the text field.
what changes should be made in the above coding?

Upvotes: 2

Views: 3297

Answers (3)

Abdelilah Lbardi
Abdelilah Lbardi

Reputation: 104

if you want to remove the label you need to use:

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

For a full control of the label of an input, the best way is to use it like this:

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

Upvotes: 4

r3mmel
r3mmel

Reputation: 656

if you want to change the label, use this.

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

Upvotes: 5

joshua.paling
joshua.paling

Reputation: 13952

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

Or, if you wanted to change the label to something else of your choosing:

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

Upvotes: 1

Related Questions