如何检索数据并更新表单中的内容

时间:2014-04-16 09:25:20

标签: cakephp-2.0

控制器 usercontroller.php

public function mydetails() {
        $this->loadmodel('Mydetails');

     if ($this->request->is('post')) {
 $this->request->data['Mydetails']['doctor_id'] = $_SESSION['UserAuth']['User']['id'];
            if ($this->Mydetails->save($this->request->data)) {
                $this->Session->setFlash(__('Your Appointment has received.'));
            } else {
                $this->Session->setFlash(__('Unable to add your Appointment.'));
            }
}

    }

这里我使用医生ID保存了数据 查看

mydetails.ctp

<div class="umtop">
    <?php echo $this->Session->flash(); ?>
    <?php echo $this->element('dashboard'); ?>
    <div class="um_box_up"></div>
    <div class="um_box_mid">
        <div class="um_box_mid_content">
            <div class="um_box_mid_content_top">
                <span class="umstyle1"><?php echo __('Doctor Details'); ?></span>
                <span class="umstyle2" style="float:right"><?php echo $this->Html->link(__("Home",true),"/") ?></span>
                <div style="clear:both"></div>
            </div>
            <div class="umhr"></div>
            <div class="um_box_mid_content_mid" id="register">
                <div class="um_box_mid_content_mid_left">
                    <?php echo $this->Form->create('Mydetails'); ?>

                    <div>
                        <div class="umstyle3"><?php echo __('Specialties');?><font color='red'>*</font></div>
                        <div class="umstyle4" ><?php echo $this->Form->input("specialties" ,array("type"=>"textarea",'label' => false,'div' => false,'class'=>"umstyle5" ))?></div>
                        <div style="clear:both"></div>
                    </div>
                    <div>
                        <div class="umstyle3"><?php echo __('Expertise');?><font color='red'>*</font></div>
                        <div class="umstyle4" ><?php echo $this->Form->input("expertise" ,array("type"=>"textarea",'label' => false,'div' => false,'class'=>"umstyle5" ))?></div>
                        <div style="clear:both"></div>
                    </div>
                    <div>
                        <div class="umstyle3"><?php echo __('Education');?><font color='red'>*</font></div>
                        <div class="umstyle4" ><?php echo $this->Form->input("education" ,array("type"=>"textarea",'label' => false,'div' => false,'class'=>"umstyle5" ))?></div>
                        <div style="clear:both"></div>
                    </div>
                    <div>
                        <div class="umstyle3"><?php echo __('Experience');?><font color='red'>*</font></div>
                        <div class="umstyle4" ><?php echo $this->Form->input("experience" ,array("type"=>"textarea",'label' => false,'div' => false,'class'=>"umstyle5" ))?></div>
                        <div style="clear:both"></div>
                    </div>
                    <div>
                        <div class="umstyle3"><?php echo __('Awards & Honours');?><font color='red'>*</font></div>
                        <div class="umstyle4"><?php echo $this->Form->input("awards" ,array("type"=>"textarea",'label' => false,'div' => false,'class'=>"umstyle5" ))?></div>
                        <div style="clear:both"></div>
                    </div>
                    <div>
                        <div class="umstyle3"><?php echo __('Research');?><font color='red'>*</font></div>
                        <div class="umstyle4"><?php echo $this->Form->input("research" ,array("type"=>"textarea",'label' => false,'div' => false,'class'=>"umstyle5" ))?></div>
                        <div style="clear:both"></div>
                    </div>
                    <div>
                        <div class="umstyle3"></div>
                        <div class="umstyle4"><?php echo $this->Form->Submit(__('Add Details'));?></div>
                        <div style="clear:both"></div>
                    </div>
                    <?php echo $this->Form->end(); ?>
                </div>
                <div class="um_box_mid_content_mid_right" align="right"></div>
                <div style="clear:both"></div>
            </div>
        </div>
    </div>
    <div class="um_box_down"></div>
</div>
<script>
document.getElementById("UserUserGroupId").focus();
</script>

模型

Mydetails.php

App::uses('UserMgmtAppModel', 'Mydetails.Model');
App::uses('CakeEmail', 'Network/Email');

class Mydetails extends UserMgmtAppModel {


}

上面的代码可以正常保存详细信息,但我需要在内容已填入框中时使用更新,

0 个答案:

没有答案