I am making a website to make requests for premises in a university
I have a table with reference to the teachers who make the requests for the premises and another regarding the requests (request_made) that has a field that refers to the table request_made
I have the classes TeacherType.php and Request_MadeType.php which are the teacher and request_made forms respectively
I need to show a form that contains the two forms together
How could I do it?
Here I show you the classes of the entities and the forms
/**
* Class request_made
* @package PrimaryBundle\Entity
* @ORM\Entity
*/
class request_made{
...
/**
* @ORM\ManyToOne(targetEntity="local")
* @ORM\JoinColumn(name="local_id", referencedColumnName="id")
*/
private $local;
/**
* @ORM\ManyToOne(targetEntity="teacher")
* @ORM\JoinColumn(name="teacher_id", referencedColumnName="id")
*/
private $teacher;
...
/**
* Class teacher
* @package PrimaryBundle\Entity
* @ORM\Entity
*/
class teacher{
...
Application Form
class Request_MadeType extends AbstractType{
public function buildForm(FormBuilderInterface $builder, array $options){
$builder
->add('local', EntityType::class, array(
'class' => 'PrimaryBundle:local',
'choice_label' => 'name',
'label' => 'Seleccione el local'
))
->add('teacher', EntityType::class, array(
'class' => 'PrimaryBundle:teacher',
'choice_label' => 'first_name',
'label' => 'Seleccione el profesor'
))
->add('start_time', TimeType::class, array('label' => 'Hora inicio'))
->add('end_time', TimeType::class, array('label' => 'Hora fin'))
->add('date', DateType::class, array('label' => 'Día'))
->add('subject', TextType::class, array('label' => 'Asignatura'))
->add('faculty', TextType::class, array('label' => 'Facultad'))
// ->add('state', IntegerType::class, array('label' => 'Estado'))
->add('save', SubmitType::class, array('label' => 'Insertar Datos'))
;
}
public function configureOptions(OptionsResolver $resolver){
$resolver->setDefaults(array('data_class' => 'PrimaryBundle\Entity\request_made',));
}
}
Teachers Form
class TeacherType extends AbstractType{
public function buildForm(FormBuilderInterface $builder, array $options){
$builder
->add('first_name', TextType::class, array('label' => 'Nombre'))
->add('last_name', TextType::class, array('label' => 'Apellidos'))
->add('ci', TextType::class, array('label' => 'CI'))
->add('teaching_category', TextType::class, array('label' => 'Categoría Docente'))
->add('scientific_category', TextType::class, array('label' => 'Categoría Científica'))
->add('user_name', TextType::class, array('label' => 'Nombre de Usuario'))
->add('save', SubmitType::class, array('label' => 'Insertar Datos'))
;
}
public function configureOptions(OptionsResolver $resolver){
$resolver->setDefaults(array('data_class' => 'PrimaryBundle\Entity\teacher',));
}
}