rendered paste bodyCONTROLADOR:
<?php
class MylogsController extends AppController {
var $name = 'Mylogs';
var $helpers = array('Html', 'Form' );
function beforeSave()
{
$actionId = $this->data['Mylog']['action_id'];
$mivar=$this->Mylog->Action->find("first", array("id" => $actionId));
//$mivar=$this->Action->read("null", $actionId);
//$prize = $mivar["Action"]["prize"];
//$this->data["Myog"]["prize"] = $prize;
debug($mivar);
debug($this->data);
}
function admin_index() {
$this->layout = 'admin';
$this->Mylog->recursive = 0;
$this->set('mylogs', $this->paginate());
}
function admin_view($id = null) {
$this->layout = 'admin';
if (!$id) {
$this->Session->setFlash('Invalid Mylog.');
$this->redirect(array('action'=>'index'), null, true);
}
$this->set('mylog', $this->Mylog->read(null, $id));
}
function admin_add() {
$this->layout = 'admin';
//echo "hola"; print_r($mivar); echo "hola";
//$actionId = $this->data['Mylog']['action_id'];
//$mivar=$this->Mylog->Action->find("first", array("id" => $actionId));
//debug($mivar);
if (!empty($this->data)) {
$this->cleanUpFields();
$this->Mylog->create();
if ($this->Mylog->save($this->data)) {
//$this->Session->setFlash('The Mylog has been saved');
$this->redirect(array('action'=>'index'), null, true);
} else {
//$this->Session->setFlash('The Mylog could not be saved. Please, try again.');
}
}
$domains = $this->Mylog->Domain->generateList();
$actions = $this->Mylog->Action->generateList();
$this->set(compact('domains', 'actions'));
}
function admin_edit($id = null) {
$this->layout = 'admin';
if (!$id && empty($this->data)) {
$this->Session->setFlash('Invalid Mylog');
$this->redirect(array('action'=>'index'), null, true);
}
if (!empty($this->data)) {
$this->cleanUpFields();
if ($this->Mylog->save($this->data)) {
$this->Session->setFlash('The Mylog has been saved');
$this->redirect(array('action'=>'index'), null, true);
} else {
$this->Session->setFlash('The Mylog could not be saved. Please, try again.');
}
}
if (empty($this->data)) {
$this->data = $this->Mylog->read(null, $id);
}
$domains = $this->Mylog->Domain->generateList();
$actions = $this->Mylog->Action->generateList();
$this->set(compact('domains','actions'));
}
function admin_delete($id = null) {
if (!$id) {
$this->Session->setFlash('Invalid id for Mylog');
$this->redirect(array('action'=>'index'), null, true);
}
if ($this->Mylog->del($id)) {
$this->Session->setFlash('Mylog #'.$id.' deleted');
$this->redirect(array('action'=>'index'), null, true);
}
}
}
?>
-------------------------------------------------------------------
VISTA:
<div id="left">
<div class="mylog">
<?php echo $form->create('Mylog');?>
<fieldset>
<legend><?php echo sprintf(__('Add %s', true), __('Mylog', true));?></legend>
<?php
echo $form->input('domain_id');
echo $form->input('action_id');
echo $form->input('price');
echo $form->input('finished');
?>
</fieldset>
<?php echo $form->end('Submit');?>
</div>
</div>
<div class="actions">
<h2>Mylogs</h2>
<ul>
<li><?php echo $html->link(sprintf(__('List %s', true), __('Mylogs', true)), array('action'=>'index'));?></li>
</ul>
<h2>Domains</h2>
<ul>
<li><?php echo $html->link(sprintf(__('List %s', true), __('Domains', true)), array('controller'=> 'domains', 'action'=>'index')); ?> </li>
<li><?php echo $html->link(sprintf(__('New %s', true), __('Domain', true)), array('controller'=> 'domains', 'action'=>'add')); ?> </li>
</ul>
<h2>Actions</h2>
<ul>
<li><?php echo $html->link(sprintf(__('List %s', true), __('Actions', true)), array('controller'=> 'actions', 'action'=>'index')); ?> </li>
<li><?php echo $html->link(sprintf(__('New %s', true), __('Action', true)), array('controller'=> 'actions', 'action'=>'add')); ?> </li>
</ul>
</div>