1

i have two tables

voices:

  • id
  • Lecturer_id
  • ...

Lecturers:

  • id
  • Lecturer
  • code

add.ctp is for voices but there is a drop-down which list lecturers. then the id of Lecturer should be saved in Lecturer_id of voices table

1 Answer 1

3

i solved the issue and wanted to share it with u:

in Voice module:

public $belongsTo = 'Lecturer';

and i added some code to Add action in Voicescontroller:

    $this->set('lecturers', $this->Voice->Lecturer->find(
            'list',
            array(
                'fields' => array('Lecturer.Lecturer'),
                'order' => array('Lecturer.Lecturer')
            )));

and in add.ctp for my dropdown:

        echo $this->Form->input('lecturer_id',  array(
            'options' => array($lecturers),
            'empty' => '(choose one)'
             ));
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.