Try this for your model
<?php class Detail extends AppModel {
        var $validate = array(
                'name' => array('rule' => 'notEmpty'),
                'age' =>  array('rule' => 'notEmpty'),
                'class_id' => array('rule' => 'notEmpty')
        );
}
?>

On Sep 16, 11:01 am, "Mike Karthauser" <mi...@brightstorm.co.uk>
wrote:
> On Thu, September 16, 2010 7:43 am, Anoop Sankar wrote:
> > I am new to CakePHP.
> > Here i am pasting my standards_controller.php , new_student.ctp and
> > the model detail.php
>
> > <?php
> > class StandardsController extends AppController {
>
> >    var $name = 'Standards';
> >    //var $uses = array('Standard','Detail');
> >    var $components = array('Session');
>
> >    function add()
> >    {
> >            if(!empty($this->data)) {
> >                    if($this->Standard->save($this->data)) {
> >                            $this->Session->setFlash('Inserted new class!!');
> >                            $this->redirect(array('action' => 'index'));
> >                    }
> >            }
> >    }
>
> >    function new_student()
> >    {
> >            $class_details = $this->Standard->query("
>
> > SELECT id, class_name
> >                                                                          
> > FROM standards
> >                                                                    ");
> >            $this->set('class_details',$class_details);
> >            if(!empty($this->data)) {
> >                    if($this->Detail->save($this->data)) {
> >                            $this->Session->setFlash("Details saved 
> > successfully");
> >                            $this->redirect(array('action' => 'index'));
> >                    }
> >                    else {
> >                            $this->Session->setFlash("An error occured 
> > during insertion,Please
> > try again!!");
> >                            $this->redirect(array('action' => 'index'));
> >                    }
> >            }
> >    }
> > }
> > ?>
>
> > Below is new_student.ctp
> > <?php
> >    echo $form->create(array('action' => 'new_student'));
> >    echo $form->text('name');
> >    for($i = 1; $i < 100; $i++)
> >    {
> >            $options[$i] = $i;
> >    }
> >    echo $form->select('Age',$options);
> >    foreach($class_details as $class_det)
> >    {
> >            $class_id[$class_det['standards']['id']] = 
> > $class_det['standards']
> > ['class_name'];
> >    }
> >    echo $form->select('Class',$class_id);
> >    echo $form->submit('Save');
> >    echo $form->end();
> > ?>
>
> > And here is detail.php
> > <?php
> >    class Detail extends AppModel {
> >            $name = "Detail";
> >            $validate = array(
> >                                            'name' => array('rule' => 
> > 'notEmpty')
> >                                            'age' =>  array('rule' => 
> > 'notEmpty')
> >                                            'class_id' => array('rule' => 
> > 'notEmpty')
> >                                            );
> >    }
> > ?>
>
> > The problem is that we i uncomment the var
> > $uses=array('Detail','Standard') it shows an error message,that i
> > pasted below.
>
> > Parse error: syntax error, unexpected T_VARIABLE, expecting T_FUNCTION
> > in C:\xampp\htdocs\second_project\app\models\detail.php on line 3
>
> tbh if you've correctly built your model relationships there should be no
> need to use uses array. Not that that is the problem in this case.
>
> so whats wrong in the detail model line 3?
>
> mikek
>
> --
> Mike Karthauser
> Managing Director - Brightstorm Ltd
>
> Email: mi...@brightstorm.co.uk
> Web:http://www.brightstorm.co.uk
> Tel:  07939 252144 (mobile)
> Fax: 0870 1320560
>
> Address: 1 Brewery Court, North Street, Bristol, BS3 1JS

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 cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to