2011-06-30 123 views
1

我有一个网站,我希望用户注册到特定的组。为了访问该组,您需要知道他们的组织ID和组织密码。构建CakePHP注册页面

我试图创建一个表单,这将使我能够确认该组ID和密码存在并且是正确的,然后创建一个新用户。我想验证用户表单中的所有字段,如果他们不工作,让他们自动奇迹般地打印错误。

讽刺的是,当我“烤”我的应用程序会创建形式,成功地显示错误消息。但出于某种原因,我无法用我的自定义表单打印出任何验证错误。

我这样做的方法是:

<div class="full center"> 
     <? 
      echo $this->Session->flash(); 
      echo $this->Session->flash('auth'); 
     ?> 
     <h3>Organization ID/Registration Code</h3> 
     <?php 
      echo $this->Form->create('User', array('action'=>'register_user')); 
      echo $this->Form->input('Organization.id', array('type'=>'text', 'label' => 'Organization ID')); 
      echo $this->Form->input('Organization.registration_code', array('label' => 'Organization Registration Code')); ?> 
     <h3>User Account Information </h3> 
     <?php 
      echo $this->Form->input('User.email'); 
      echo $this->Form->input('User.password', array('value'=>'')); 
      echo $this->Form->input('User.name'); 
      echo $this->Form->input('User.xxxx'); 
      echo $this->Form->input('User.xxxx'); 
      echo $this->Form->input('User.xxxx'); 
      echo $this->Form->input('User.xxxx'); 
     ?> 
     <div><input type="checkbox" name="data[tos][agree]"> I agree to the Terms of Service.</div> 
     <div><input type="checkbox" name="data[pp][agree]"> I agree to the Privacy Policy.</div> 
     <?php echo $this->Form->end(__('Join my Organization', true));?> 
</div> 

但没有什么工作!请让我知道,如果这是正确的方式来构建这种类型的注册表格,以及如何让我的错误显示!

而且,我需要,我在这两个用户的信息和组织的信息正在采取类似的注册页面,然后创建组织,用户和用户添加到组织。那将如何构建?

谢谢!

回答

1
<div class="full center"> 
    <? 
     if($session->check('Message.flash')) 
     { 
     echo $this->Session->flash(); 
     echo $this->Session->flash('auth'); 
     } 
    ?> 
    <h3>Organization ID/Registration Code</h3> 
    <?php 
     echo $this->Form->create('User', array('action'=>'register_user')); 
     echo $this->Form->input('Organization.id', array('type'=>'text', 'label' => 'Organization ID')); 
     echo $this->Form->input('Organization.registration_code', array('label' => 'Organization Registration Code')); ?> 
    <h3>User Account Information </h3> 
    <?php 
     echo $this->Form->input('User.email'); 
     echo $this->Form->input('User.password', array('value'=>'')); 
     echo $this->Form->input('User.name'); 
     echo $this->Form->input('User.xxxx'); 
     echo $this->Form->input('User.xxxx'); 
     echo $this->Form->input('User.xxxx'); 
     echo $this->Form->input('User.xxxx'); 
    ?> 
    <div><input type="checkbox" name="data[tos][agree]"> I agree to the Terms of Service.</div> 
    <div><input type="checkbox" name="data[pp][agree]"> I agree to the Privacy Policy.</div> 
    <?php echo $this->Form->end(__('Join my Organization', true));?>