Reputation: 2157
I am using Cakephp 2 and i do generate html content into an action I need to send the html content to a blank view.
I have the controller action send :
public function send() {
if ($this->request->is('get')) {
$this->request->data['Doc']['value'] = 0.01;
$this->request->data['Doc']['name'] = 'OneName';
}
if ($this->request->is('post')) {
echo $this->generate($this->request->data);
}
}
And the action generate :
public function generate($data) {
$html= new htmlGenerator($data);
return $html->getOutput();
}
I have the views send.ctp
and generate.ctp
When i do send the form the html generated stays at the top of the current view
How can i send to generate.ctp view passing this->request->data to generate action ?
Upvotes: 0
Views: 39
Reputation: 1268
This should be something like this
public function send() {
$this->autoRender = false;
if ($this->request->is('get')) {
$this->request->data['Doc']['value'] = 0.01;
$this->request->data['Doc']['name'] = 'OneName';
$this->render('path/to/your/send');
}
if ($this->request->is('post')) {
$this->set('generated',$this->generate($this->request->data));
$this->render('path/to/your/generate');
}
}
and then in your generate.ctp
<?php echo $generated ?>
Upvotes: 1