Hi to all,
I have created the following (simple) Model.
<?php
class Content extends AppModel {
var $name = 'Content';
var $belongsTo = array(
'Section' => array(
'className' => 'Section',
'foreignKey' => 'section_id'
)
);
};
function beforeSave() {
if (!empty($this->data)) {
$this->data['Content']['title'] = 'modified by
beforeSave...';
}
return true;
}
?>
I overloaded the beforeSave() method, which simply replaces the
current title with "modified by beforeSave...";
I also created an add() method in the ContentsController, to save form-
data. The method is as follows
function admin_add() {
if (!empty($this->data)) {
$sid = $this->data['Content']['section_id'];
$cont = $this->Content->find('all', array('conditions'
=> array
('Content.section_id' => $sid)));
$this->Content->create();
if ($this->Content->save($this->data))
$this->flash('Content Saved!', 'index');
}
}
The save() method should normally call beforeSave(), (at least as
indicated by cakephp documentantion), but in my version of cakephp
(1.2.5 stable) it isn't.
I used to "embed" all the code into add() method, manually but this is
not the case for me right now.
Does anyone have any idea for this problem?
Thanx in advance
Christos
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---