Tuesday, June 28, 2011

Re: controller's save method is not working

Hi Jeremy,

The following is what i'm getting if I added die(debug($this->Student-
>ValidationErrors)) to the else stmt

merry_flowers\controllers\students_controller.php (line 12)
Array
(
)

thanks
varai

On Jun 28, 4:35 pm, Jeremy Burns | Class Outfit
<jeremybu...@classoutfit.com> wrote:
> Add an else to the if (save) command: die(debug($this->Student->validationErrors));  Maybe it's failing at the db level.
>
> Jeremy Burns
> Class Outfit
>
> http://www.classoutfit.com
>
> On 28 Jun 2011, at 12:20, varai wrote:
>
>
>
> > Hi
>
> > my following students_controller.php is not saving the student info in
> > the form. I have no idea on what is the prob. I have already checked
> > the data to be saved using var_dump($this->data)
>
> > students_controller.php
> > <?php
> > class StudentsController extends AppController{
>
> > function add(){
> > if (!empty($this->data)){
> >    var_dump($this->data);
> >    if ($this->Student->save($this->data)){
> >            $this->Session->setFlash('Your child\'s admission has been
> > received. We will send you an email shortly.');
> >    $this->redirect(array('action'=>'home'));
> >                            }
> >            }
> >    }
> > }
> > ?>
>
> > add.ctp
> > <?php
> >    echo $form->create('Student', array('action'=>'add'));
> >    echo '<fieldset>';
> >    echo '<legend>Student Information</legend>';
> >    echo $form->input('Student.name');
> >    echo $form-
> >> input('Student.gender',array('type'=>'radio','options'=>array('Male'=>'Male­','Female'=>'Female'),'value'=>'Male'));
> >    echo $form->input('Student.dob',
> > array('label'=>'DOB','dateFormat'=>'DMY'));
> >    echo $form->input('Student.class_id', array('label'=>'Enquiry Class
> > for',
> >    'options'=>array('1'=>'Playgroup','2'=>'Nursery','3'=>'LKG',
> > '4'=>'UKG'),'selected'=>'1'));
> >    echo '</fieldset>';
>
> >            echo $form->end('Submit');
>
> > ?>
>
> > --
> > Our newest site for the community: CakePHP Video Tutorialshttp://tv.cakephp.org
> > Check out the new CakePHP Questions sitehttp://ask.cakephp.organd help others with their CakePHP related questions.
>
> > To unsubscribe from this group, send email to
> > cake-php+unsubscribe@googlegroups.com For more options, visit this group athttp://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
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: