【问题标题】:CakePHP Observe field for validation check(already exists)CakePHP 观察字段进行验证检查(已经存在)
【发布时间】:2012-12-15 05:01:46
【问题描述】:
  1. 我已经在 cakephp 1.3 中有用户观察字段现在我想在 cakephp 2.0 中做同样的事情 我有一个表格。有一个名为电子邮件的字段。当用户插入电子邮件时。 onblur 弹出一条消息,显示“电子邮件已存在”或“正确”

为此,我在我的项目中编写了以下代码。下面的代码是我的添加文件代码

<?php $options = array('url' => array( 'controller' => 'users', 'action' => 'is_exist'), 'update' => 'email_exist');
        echo $this->ajax->observeField('UserEmailId',array('url' => array( 'controller' => 'users', 'action' => 'is_exist'), 'update' => 'email_exists'));  ?>

在我的控制器中,我创建了一个函数,例如

 public function is_exist($id = null)
    {
    $result = "yes";
    $this->set('existdata',$result);
    }

我还在 view/uers 中创建了 is_exists.ctp 字段。 我不知道为什么它不工作。 我在 Cakephp 1.3 及其工作文件中做了同样的事情,但在 cakephp 2.0 中没有 谁能告诉我如何实现这个? 提前谢谢

【问题讨论】:

    标签: ajax cakephp-1.3 cakephp-2.0


    【解决方案1】:

    因为 cakephp 2 不支持 ajax 助手。 你需要学习如何使用 js helper 来实现它 检查此链接:js helper

    【讨论】:

      猜你喜欢
      • 2015-02-15
      • 1970-01-01
      • 1970-01-01
      • 2019-08-20
      • 2011-05-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多