donglusou3335 2011-11-24 12:09
浏览 27
已采纳

仅在字段更改时才在表单上发送电子邮件

I have a form to edit a job, a job has a status column which can be 1, 2 or 3

<?php echo $this->Form->input('status', array('label' => '', 'options' => $status)); ?>

When i submit the form i want to check if the value of status is equal to 3, if it is then i want to send an email. BUT i dont want to send the email if the value was 3 already.

Is there an easy way in cakephp to check the previous value to the new value etc?

Thanks.

  • 写回答

3条回答 默认 最新

  • dqlk31541 2011-11-24 15:40
    关注

    No need to mess with sessions, or indeed set the value beforehand.

    Basically when you edit the record, you get the current records status value from the table. If it's already 3, we do not want to send an email, so set a boolean.

    Update the record as required.

    If the status was not 3, and the new status is, send the email.

    I haven't filled in the whole method; but you should get the idea:

    $send_email = true;    
    $current_status = $this->Job->field('status');
    if($current_status==3) {
        $send_email = false;
    }
    
    // save the record
    
    if($send_email==true && $this->data['Job']['status']==3) {
       //send the email
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度