Hi Cake-Friends.
I wrote an Action to handle an Ajax-Request:
function admin_ajax_state() {
if($this->params['form']['ajax']) {
$id = $this->params['form']['id'];
$teaser = $this->Teaser->read('state', $id);
$teaser = (bool) $teaser['Teaser']['state'];
$teaser ? $teaser_val = 0 : $teaser_val = 1;
$this->Teaser->saveField('state', $teaser_val);
$this->set('msg', $teaser_val);
}
$this->layout = null;
$this->viewPath = 'pages';
$this->render('ajax_response');
}
I will need this action in different controllers, but with the same
functionality. That sounds like DRY, or?!
Is there a possibility to generalize this action? How can I make the
related Model dynamically?
e.g. $this->$DynamicModel->saveField(...);
Best Mathias
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---