Foros del Web » Programando para Internet » PHP » Symfony »

Pasar coleccion al Form

Estas en el tema de Pasar coleccion al Form en el foro de Symfony en Foros del Web. Hola amigos me encontre con un problema al crear un formulario que no puedo solucionar, necesito crear un boletin de calificaciones para una escuela, el ...
  #1 (permalink)  
Antiguo 09/01/2012, 15:27
 
Fecha de Ingreso: marzo-2009
Mensajes: 76
Antigüedad: 15 años, 1 mes
Puntos: 1
Pasar coleccion al Form

Hola amigos me encontre con un problema al crear un formulario que no puedo solucionar, necesito crear un boletin de calificaciones para una escuela, el boletin debe ser bastante simple y cuenta con algunos datos de otras clases pero no necesito relacionar las clases ya que la idea es que vaya a un historico luego y como los profesores y hasta los nombres de las materias podrian cambiar en un futuro se desea mantenerlo simple y guardar en un string los datos de interes.

Aca les dejo las clases, lo que no se como hacer el crear la CLASE BoletinType ya que creo que ahi tendria que ir en los add.

CLASE BOLETIN

Código PHP:
/**
 * @ORM\Entity(repositoryClass="Escuela\EscuelaBundle\Repository\BoletinRepository")
 * @ORM\Table(name="boletines")
 */
class Boletin {
    
/**
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue(strategy="IDENTITY")
     */
    
protected $id;
     
/**
     * @ORM\Column(type="text")
     */
    
protected $año;
    
/**
     * @ORM\ManyToOne(targetEntity="Alumno", inversedBy="boletines")
     * @ORM\JoinColumn(name="alumno_id", referencedColumnName="id")
     */
    
protected $alumno;
    
/**
     * @ORM\OneToMany(targetEntity="MateriaBoletin", mappedBy="boletin")
    */ 
    
protected $materiasBoletin;
    

CLASE MATERIABOLETIN

Código PHP:
/**
 * @ORM\Entity(repositoryClass="Escuela\EscuelaBundle\Repository\MateriaBoletinRepository")
 * @ORM\Table(name="materiasboletines")
 */
class MateriaBoletin {
    
/**
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue(strategy="IDENTITY")
     */
    
protected $id;
     
/**
     * @ORM\ManyToOne(targetEntity="Boletin", inversedBy="materiasBoletin")
     * @ORM\JoinColumn(name="boletin_id", referencedColumnName="id")
     */
    
protected $boletin;
    
/**
     * @ORM\Column(type="text")
     */
    
protected $materia;
    
/**
     * @ORM\Column(type="text")
     */
    
protected $profesor;
    
/**
     * @ORM\Column(type="text")
     */
    
protected $notaPrimerTrimestre;
    
/**
     * @ORM\Column(type="text")
     */
    
protected $notaSegundoTrimestre;
    
/**
     * @ORM\Column(type="text")
     */
    
protected $notaTerceroTrimestre;
    
/**
     * @ORM\Column(type="text")
     */
    
protected $diciembre;
    
/**
     * @ORM\Column(type="text")
     */
    
protected $marzo;
    
/**
     * @ORM\Column(type="text")
     */
    
protected $previa;

Como se ve hay una relacion OneToMany y ManyToOne entre las clases Boletin y MateriaBoletin

Las materias que van en el boletin las puedo obtener de mi (CLASE) Año ya que un año tiene muchas Materias (CLASE Materia) y lo que necesito es llegar a tener un formulario que quede algo parecido a una tabla de la siguiente forma:

NombreMateria1 INPUT_NOTA_PRIMER_TRIMESTRE - INPUT_NOTA_SEGUNDO_TRIMESTRE - INPUT_NOTA_TERCER_TRIMESTRE
NombreMateria2 INPUT_NOTA_PRIMER_TRIMESTRE - INPUT_NOTA_SEGUNDO_TRIMESTRE - INPUT_NOTA_TERCER_TRIMESTRE
NombreMateria3 INPUT_NOTA_PRIMER_TRIMESTRE - INPUT_NOTA_SEGUNDO_TRIMESTRE - INPUT_NOTA_TERCER_TRIMESTRE
NombreMateria4 INPUT_NOTA_PRIMER_TRIMESTRE - INPUT_NOTA_SEGUNDO_TRIMESTRE - INPUT_NOTA_TERCER_TRIMESTRE
NombreMateria5 INPUT_NOTA_PRIMER_TRIMESTRE - INPUT_NOTA_SEGUNDO_TRIMESTRE - INPUT_NOTA_TERCER_TRIMESTRE

Mi idea es poder crear el formulario del boletin con la clase BoletinType, para despues poder crear el form y vincular los datos del post de forma sencilla y no tenerlo que hacer a mano.

Espero que se entienda la idea y desde ya cualquier dato o ayuda sere muy bienvenido.

PARA QUE SE DEN UNA MEJOR IDEA A LO QUE QUIERO LLEGAR ES ALGO PARECIDO A REALIZAR UN FORMULARIO DE PEDIDOS DE PRODUCTOS LLEVÁNDOLO A OTRO ÁMBITO MAS COMÚN, EN DONDE EL CLIENTE VE EL LISTADO DE PRODUCTOS Y CON UN INPUT SELECCIONA LA CANTIDAD QUE DESEA DE CADA PRODUCTO, EL TEMA ES QUE NO SE COMO PASARLE ESA COLECCION "DINAMICA" DE "PRODUCTOS" AL CLASE PedidoType, PARA SEGUIR CON EL EJEMPLO DEL FORMULARIO DE PEDIDO.
BUENO EN MI CASO DEBERIA VER UN LISTADO DE MATERIAS Y COLOCAR LA NOTA DE CADA MATERIA Y LE TENDRIA QUE PASAR UNA COLECCION DE MATIRAS AL BOLETIN EN ESTE CASO A LA CLASE BoletinType sino me equivoco, ESO MISMO ES LO QUE NO SE COMO HACER Y NO LO ENCUENTRO.

Saludos y desde ya gracias.

Nico

Última edición por nicostone; 10/01/2012 a las 13:57

Etiquetas: symfony2
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 13:56.