I might be missing something, but what is the function _validationRules? Where 
is it being called from?

A normal model set up uses var $validate = array(); and that just works. Are 
you sure your validation is triggering? Are you sure that your user is really 
passing validation rules or is just saving without error? And if so, that your 
newsletter is actually failing a save at the db level when it would fail 
validation (that isn't being triggered/checked)?


Jeremy Burns
Class Outfit

http://www.classoutfit.com

On 16 Nov 2011, at 15:23, heohni wrote:

> Hi,
> 
> I have a working contact form on my project and I am about just to use
> another form within another controller.
> So I copied all from my contact model into my newsletter model:
> 
> <?php
> class Newsletter extends AppModel {
>       var $name = 'Newsletter';
>    var $useTable = 'newsletter';
> 
>    function _validationRules() {
>        $this->validate = array(
>            'news_company' => array(
>                'rule' => 'notEmpty',
>                'message' => __('Bitte tragen Sie hier Ihren Namen
> ein.', true)
>            )
>        );
>    }
> 
> }
> ?>
> 
> My Controller:
> <?php
> class NewsletterController extends AppController {
> 
>       var $name = 'Newsletter';
> 
> function surveyfinal(){
>        if ($this->RequestHandler->isPost()) {
>            if ($this->Newsletter->validates()) {
>                 echo "ok";
>             }else{
>                $this->Session->setFlash(__('Ihre Anfrage konnte nicht
> versendet werden! Bitte prüfen Sie die markierten Felder.', true));
>            }
>        }
>    }
> 
> 
> The strange thing is, that this the same like my contact form, and
> there the validation works!
> But the data (is present, proofed) is not validating.
> 
> debug($this->Newsletter->validate);
> 
> is always empty!
> 
> if I use this instead:
> var $validate = array(
>        'news_company' => array(
>            'required' => array('rule' => 'notEmpty', 'message' =>
> 'EmptyName')
>        ),
> the form is validating its data, but I need to have it multilingual,
> like in my contact form.
> 
> Within my controller I can work with $this->Newsletter. Means I can
> connect to my model. I have some other function where I read and save
> data from/to my database.
> 
> I really don't understand, why just the validation data is not
> present??
> 
> Anyone any ideas??
> 
> Thanks!!
> 
> -- 
> Our newest site for the community: CakePHP Video Tutorials 
> http://tv.cakephp.org 
> Check out the new CakePHP Questions site http://ask.cakephp.org and help 
> others with their CakePHP related questions.
> 
> 
> To unsubscribe from this group, send email to
> [email protected] For more options, visit this group at 
> http://groups.google.com/group/cake-php

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to