1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57 |
two tables:
- auth_users
- profiles
profiles_controller.php
function edit($id = null) {
if (!$id && empty($this->data)) {
$this->Session->setFlash('Invalid Profile');
$this->redirect(array('action'=>'index'), null, true);
}
if (!empty($this->data)) {
$this->cleanUpFields();
if ($this->Profile->save($this->data)) {
$this->Session->setFlash('The Profile has been saved');
$this->redirect($this->referer());
} else {
$this->Session->setFlash('The Profile could not be saved. Please, try again.');
}
}
if (empty($this->data)) {
$this->data = $this->Profile->read(null, $id);
// debug, raw
$vprofile = $this->Profile->read(null, $id);
echo '<pre>';
print_r($vprofile);
echo '</pre>';
}
}
view.ctp
<?php echo $form->create('Profile');?>
<fieldset>
<?php
echo $form->input('email');
echo $form->input('name_first');
echo $form->input('name_last');
?>
</fieldset>
model, has associations
var $belongsTo = array(
'AuthUser' => array('className' => 'AuthUser',
'joinTable' => 'auth_users',
'foreignKey' => 'auth_user_id',
'conditions' => '',
'fields' => '',
'order' => '',
'counterCache' => ''),
); |
