Bin will be removed on June 1, 2014 in favor of http://gist.github.com. Please save all your pastes before then. So long, and thanks for all the fish!×
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>
        <legend><?php echo sprintf(__('Edit %s', true), __('Profile', true));?></legend>
    <?php
        echo $form->select('type_of_user',array('Client'=>'Client','Staff'=>'Staff','Manager'=>'Manager'));
        echo $form->select('is_active',array('1'=>'Active','0'=>'In Active'));
        echo $form->input('email');
        echo $form->input('name_first');
        echo $form->input('name_last');
    ?>
    </fieldset>
<?php echo $form->end('Edit Profile');?>
 
 
model, has associations
    var $belongsTo = array(
            'AuthUser' => array('className' => 'AuthUser',
                                'joinTable'    => 'auth_users',
                                'foreignKey' => 'auth_user_id',
                                'conditions' => '',
                                'fields' => '',
                                'order' => '',
                                'counterCache' => ''),
    );