I create a action "edit" for edit one table of my database,  it apparently 
works ok but don't update designed table. It returns to previous page with 
an ok message, but the data are not changed. My action in controller are 
this:
public function edit($id){
$this->Matricula->id = $id;
    if ($this->request->is('get')) {
        $this->request->data = $this->Matricula->read(NULL, $id);
        $this->set('cursos', $this->Matricula->Curso->find('list', 
array('fields'=>array('Curso.id', 'Curso.curso'))));
        $this->set('anos', $this->Matricula->Ano->find('list', 
array('fields'=>array('Ano.id', 'Ano.ano'), )));  
        $this->set('turmas', $this->Matricula->Turma->find('list', 
array('fields'=>array('Turma.id', 'Turma.Turma'))));  
    } 
    else {
        if ($this->Matricula->save($this->request->data)) {
            $this->Session->setFlash('A matrícula foi atualizada');
            $this->redirect(array('action' => 'index'));
        }
    }

 }

And this is my edit.ctp
<div style="font-size:16pt; font-height: strong"><?php echo 
$this->request->data['Aluno']['aluno'];?> <br><br> </div>

<?php
    echo $this->Form->create('Matricula', array('action' => 'edit'));
    
   echo $this->Form->input('curso', array('type'=>'select', 
'label'=>'Curso', 'options'=>$cursos, 
'selected'=>$this->request->data['Curso']['id']));

    #echo "Curso: ".$this->Form->select('curso', $curso);
    echo $this->Form->input('ano', array('type'=>'select', 
'label'=>'Série', 'options'=>$anos, 
'selected'=>$this->request->data['Ano']['id']));
    echo $this->Form->input('turma', array('type'=>'select', 
'label'=>'Turma', 'options'=>$turmas, 
'selected'=>$this->request->data['Turma']['id']));
    echo $this->Form->input('id', array('type' => 'hidden'));
    echo $this->Form->end('Alterar');
       ?>

What is wrong with my code?




-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Reply via email to