views:

201

answers:

1

Hi,

I am building a web application using Symfony 1.4 and Doctrine for a school and I want to make a very simple form to add a course to a student.

The main problem I have is that in the drop down list I only want to show the courses in which the student is currently not enrolled.

I already have a function in the model (in Student.class.php) which returns all the courses in which the student is not enrolled but the problem is I don't know how to pass the student to the configure() of the form. I have tried several options like passing it with the constructor of the form to a global variable or a special set method but none of them have worked.

Is there any form to pass the student to the configure() method?

Thanks!

+2  A: 

This should work for you...

In your action:

$this->form = new StudentCourseForm(array(), array('student_id' => $student_id));

In the form class:

$this->getOption('student_id');
Tom
Actually it is : $this->form = New StudentCourseForm(array(), array('student_id' => $student_id));
DuoSRX
Of course. I've adjusted the code.
Tom