Reputation: 17
I've some problem in cakephp to send/receive an input form
// /View/Services/add_services.ctp
....
<?php echo $this->Form->create('Service', array('action'=>'addServices'))?>
<?php echo $this->Form->input("service_name", array('label'=>false, 'div'=>false, 'class'=>"umstyle5"))?>
<?php echo $this->Form->Submit(__("Add service Type"))?>
<?php echo $this->Form->end();?>
// /Controller/ServicesController
....
public function addServices(){
....
$service_name = $_POST[service_name];
....
}
The problem is that I receive this error:
Undefined index: service_name [APP/Controller/ServicesController]
What is wrong? Thanks!!
Upvotes: 0
Views: 47
Reputation: 704
I suggest you please check the Documentation properly,
There are clearly mentioned that we can fetch data like...
//Controller/RecipesController.php:
public function edit($id = null) {
if (empty($this->request->data)) {
$this->request->data = $this->Recipe->findById($id);
} else {
// Save logic goes here
}
}
Upvotes: -1
Reputation: 2025
Use $this->request->data.
public function addServices(){
....
$service_name = $this->request->data['Service']['service_name'];
....
}
Upvotes: 2