Structuring a CakePHP Registration Page

瘦欲@ 提交于 2019-12-24 07:19:35

问题


I have a site where I want users to register to particular groups. In order to access that group, you need to know their Organization ID and Organization Password.

I am trying to create a form which will allow me to validate that the Group ID and Password exist and are correct, then create a new User. I want to Validate all of the fields in the User form and have them auto-magically print errors if they do not work.

Ironically, when I "baked" my application it creates forms which successfully show error message. For SOME reason, though, I cannot get it to print out any validation errors with my custom form.

The way I am doing this is:

<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>

But nothing is working! Please let me know if this is the correct way to structure this type of registration form and how to get my errors showing up!!!

Also, I'll need a similar registration page where I am taking in both a User's information and an Organization's information, then create the organization and the user and add the user to the Organization. How would that be structured?

Thanks!


回答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));?>



来源:https://stackoverflow.com/questions/6529023/structuring-a-cakephp-registration-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!