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
2 Answers
Your code should be like this:
echo $this->Form->input('firstname', array('class'=>'form-control','label'=>'First Name'));
2 Comments
PHP.Newbie
sir i followed this. But still I can't display the data i set in the controller to display as the default value of inputs when edit button is click.
PHP.Newbie
i set a value property to the data from the data echo $this->Form->input('firstname', array('class'=>'form-control', 'label'=>'First Name:', 'default'=>$contact['Contact']['firstname'])); to make it as a default value. And now i am able to edit the current data. Thank you sir!
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'));
2 Comments
PHP.Newbie
sir i followed this. But still I can't display the data i set in the controller to display as the default value of inputs when edit button is click.
PHP.Newbie
i set a value property to the data from the data echo $this->Form->input('firstname', array('class'=>'form-control', 'label'=>'First Name:', 'default'=>$contact['Contact']['firstname'])); to make it as a default value. And now i am able to edit the current data. Thank you sir!
nameattribute?