2011-06-30 120 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));?>