I have started working with CakePHP a week ago and trying to make a
simple Quiz page. I have used scaffolding to get a good understanding
of the model part. Everything works fine, except for /cakecms/
questions/add.It beautifully lists qid with the names of 'quizzes' in
a dropdown select box.

Unfortunately no matter what I fill in, it shows the following error
in a orange bar: "Please correct errors below.". While normally the
input-fields would have a red text with the error message in it, there
are no errors mentioned there.

I have no idea how to find out what I am doing wrong and if my model
has not been set-up correctly. I have not yet added good validation as
I wanted to get the simple model working first, before fattening it.

Quiz Model:
<?php
class Quiz extends AppModel {
        var $name = 'Quiz';
        var $displayField = 'name';
        var $validate = array(
                'name' => array(
                        'notempty' => array(
                                'rule' => array('notempty'),),),
        );

        var $hasMany = array(
                'Question' => array(
                        'className' => 'Question',
                        'foreignKey' => 'qid',
                        'dependent' => false
                )
        );

}
?>

Question Model:
<?php
class Question extends AppModel {
        var $name = 'Question';
        var $displayField = 'question';
        var $validate = array(
                'id' => array(
                        'notempty' => array(
                                'rule' => array('notempty'),),),
                'qid' => array(
                        'numeric' => array(
                        'notempty' => array(
                                'rule' => array('notempty'),),),),
                'question' => array(
                        'notempty' => array(
                                'rule' => array('notempty'),),),
                'r_answer' => array(
                        'notempty' => array(
                                'rule' => array('notempty'),),),
                'answer1' => array(
                        'notempty' => array(
                                'rule' => array('notempty'),),),
                'answer2' => array(
                        'notempty' => array(
                                'rule' => array('notempty'),),),
                'answer3' => array(
                        'notempty' => array(
                                'rule' => array('notempty'),),),
                'answer4' => array(
                        'notempty' => array(
                                'rule' => array('notempty'),),),
        );

        var $belongsTo = array(
                'Quiz' => array(
                        'className' => 'Quiz',
                        'foreignKey' => 'qid'   )
        );
}
?>

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" 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