File: models/user.php
class User extends AppModel
{
var $name = 'User';
var $validate = array(
'login' => '/[a-z0-9\_\-]{3,}$/i',
);
}
File: controllers/users_controller.php
class UsersController extends AppController
{
var $name = 'Users';
function index()
{
$this->set('users', $this->User->findAll());
}
function join()
{
if (!empty($this->data))
{
if ($this->User->save($this->data))
{
$this->flash('Done', '/users');
}
}
}
}
File: views/users/join.thtml
<h2>Join my club</h2>
<form method="post" action="<?php echo $html->url('/users/join') ?>">
<p>
<label for="login">login:</label>
<?php echo $html->input('User/login') ?>
<?php echo $html->tagErrorMsg('User/login', 'login incorrect:')
?>
</p>
<p>
<?php echo $html->submit('加入') ?>
</p>
</form>
then, open browser and input \aaa in the login input field
the problem is coming, i did't set \ character in my validates array,
why cakephp let it pass ?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---