Structuring a CakePHP Registration Page
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.
开发者_JS百科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!
<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));?>
精彩评论