PHP.Newbie
PHP.Newbie

Reputation: 195

How can i change the name of the input in cakephp

i want change the name of the input to make it name=data[Contact][firstname] because I want to display the data when i click edit() i guess that is the reason why it is not displaying. echo $this->Form->input('First Name:', array('class'=>'form-control')); the name of the input is same n the first param. please help

Upvotes: 0

Views: 1596

Answers (2)

puppy
puppy

Reputation: 57

The first parameter is the name of the input field (name="firstname"). It is not the label (First name: ). so your code should be,

$this->Form->input('firstname', array('class'=>'form-control'));

To get this structure [Contact][firstname], your form name should be 'contact'.

$this->Form->create('Contact',array('class'=>'form'));
    $this->Form->input('firstname', array('class'=>'form-control'));

Upvotes: 1

Malik Perang
Malik Perang

Reputation: 400

Your code should be like this:

echo $this->Form->input('firstname', array('class'=>'form-control','label'=>'First Name'));

Upvotes: 1

Related Questions