Hi toghether,

I have discovered some strange behavior while building a registration
component for my app. I have tried different cake versions and latest
nightly build.

Easy example for User Model:
var $validate = array(
        'firstname'  => VALID_NOT_EMPTY,
        'lastname'   => VALID_NOT_EMPTY,
        'agb'   => VALID_NOT_EMPTY
);

Registration Controller:

class RegistrationController extends AppController
{
    var $name = "Registration";
    var $uses = array('User');
    function index()
    {
           if (!empty($this->data)) {
                if ($this->User->create($this->data) && $this->User-
>validates()) {
                    $this->set('valid', true);
                    if ($this->User->save($this->data))
                    {
                        $this->flash('Your post has been saved.','/
posts');
                    }
                }
            }
            else {
                $this->render();
            }
    }
}

I was wondering that every time I tried to validate my post data
validation result is true.

My original view:
<?php echo $form->create('Registration', array('type' => 'post', 'url'
=> '/registration/')); ?>
Data is not validated and an empty row is insert into database.

If I change into
<?php echo $form->create('User', array('type' => 'post', 'url' => '/
registration/')); ?>
validation behaves correct. Saving data also.

I would expect if I post data[Registration][firstname] may it will not
be validated, ok my fault, but validation should detect that there is
no data[User][firstname] and abort saving? Any suggestions ?

Regards,
Andreas


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

Reply via email to