Hi all,
I'm experiencing the same problem, no errormessages get displayed,
though $this->User->invalidFields() does contain a few. validateErrors
appears not to work. Could this indeed be caused by PHP4 not passing
vars by reference in the case where my User model is passed to
validateErrors() ? I read about this in trac.
If so - or any other case - how to fix this?
Any help is greatly appreciated!
Best regards,
Romano
The code:
$this->set( 'username_error', 'Name needs to contain 6 to 30
characters.' );
if ( !empty( $this->data ) )
{
$this->User->set( $this->data ); // already validates data
setting up
errormsgs
if ( $this->User->validates() )
{
if ( $this->User->findByUsername( $this->data['User']
['username'] ) )
{
$this->User->invalidate( 'username' );
$this->set( 'username_error', 'Name is already in use,
pick
another.');
}
else
{
...... do some stuff ........
$this->redirect( '/users/postregister' );
exit();
}
}
else
{
$this->validateErrors( $this->User ); // fills errorTag stuff
}
}
On 16 apr, 23:31, "Aaron Thies" <[EMAIL PROTECTED]> wrote:
> I had validation all working fine with my table-less model in CakePHP
> 1.1 and then I moved to CakePHP 1.2 for the internationalization
> functionality. Now my validation is not working. I figured out I
> have ot change my $html->tagErrorMsg() to $form->error() but now my
> error messages are not dispayed?
>
> here is a portion of my view:
>
> <form action="<?=$html->url('/user/register')?>" method="post"
> accept-charset="utf-8" class="csForm">
>
> <fieldset>
> <legend><?__("header_your_info")?></legend>
> <div>
> <label><?=REQUIRED?><?__("label_first_name")?></label>
> <?=$html->input('user.first_name', array('maxlength' => 50))?>
> <?=$form->error('user.first_name', 'First Name Required')?>
> </div>
>
> here is a portion of my controller:
>
> function register() {
> Configure::load('config');
> $this->pageTitle = SITE_NAME . ' | Register';
> $this->set('page_header', 'Register');
>
> // view variables
> $this->set('countries', Configure::read('countries'));
> $this->set('country', $this->data['user']['country']);
> $this->set('province_error', '');
> $this->set('salutations', Configure::read('salutations'));
> $this->set('states', Configure::read('states'));
>
> if (!empty($this->data)) { // was anything submitted?
>
> // state or province?
> if (strcasecmp($this->data['user']['country'], 'USA') == 0) {
> if (strlen(trim($this->data['user']['state'])) == 0) {
> $this->User->invalidate('state');
> $this->set('province_error', 'State Required');
> }
> } else {
> if (strlen(trim($this->data['user']['province'])) == 0) {
> $this->User->invalidate('province');
> $this->set('province_error', 'Province Required');
> }
> }
>
> //if ($this->User->validates($this->data['user'])) {
> if ($this->User->validates()) {
>
> ...
>
> } else {
> $this->validateErrors($this->User);
> }
>
> } else {
> $this->render(); // form not submitted
> }
> }
>
> --
> Aaron Thies
>
> "When you're married you'll understand the value of fresh produce."
> - Tony Soprano
--~--~---------~--~----~------------~-------~--~----~
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?hl=en
-~----------~----~----~----~------~----~------~--~---