Try this:

public function configure() {
               parent::configure();

               /*code portion removed*/

               $alumno_interno = $this->getObject()->AlumnoInterno(); //if
the object Alumno is new it gives you an empty AlumnoInterno object, else it
gives you the associated AlumnoInterno

               $alumno_interno_form = new
AlumnoInternoForm($alumno_interno);

               $this->embedForm('alumno_interno',
$alumno_interno_form);

               /*code portion removed*/
       }

another way is to use embedRelation('AlumnoInterno') so you don't have to
deal with the save and getting the relation object to construct the subform

Hope it works

saludos

2010/9/10 Alejandro Gómez <alejandro.go...@alejandrogomez.org>

> Hi folks.
>
> The database has two tables: 'alumno' and 'alumno_interno'. The
> 'alumno' table contains general data about students: name, lastname,
> address, etc. The 'alumno_interno' table contains details about the
> student: grade, control number, etc.
>
> The relationship between tables is:
>
> alumno {id, /*more fields*/}
> alumno_interno {id, id_alumno, /*more fields*/}
>
> On Symfony I built the models and forms. In fact, AlumnoInternoForm is
> already embedded on AlumnoForm.
>
> [code]
>
> /* AlumnoForm.class.php */
>
>        public function configure() {
>                parent::configure();
>
>                /*code portion removed*/
>
>                $alumno_interno = new AlumnoInterno;
>                $alumno_interno->setAlumno($this->getObject());
>
>                $alumno_interno_form = new
> AlumnoInternoForm($alumno_interno);
>
>                $this->embedForm('alumno_interno',
> $alumno_interno_form);
>
>                /*code portion removed*/
>        }
>
> [/code]
>
> I'm able to save a new student and his or her details in 'alumno' and
> 'alumno_interno' respectively.
>
> The trouble is when I try to edit an 'alumno' object: the AlumnoForm
> renders well and shows the embedded form (AlumnoInternoForm). The
> student's data is retrieved from the 'alumno' table but not from the
> 'alumno_interno' table. So, the AlumnoForm is well populated but the
> AlumnoInteroForm isn't. It's populated with the defaults values.
>
> I think I need to override a AlumnoForm method, maybe
> updateDefaultsFromObject(). Well, I did. But It didn't work. :-(
>
> Basically, I need to retrieve the AlumnoInterno object related to the
> Alumno object from the main form -AlumnoForm-, put the AlumnoInterno
> object inside the AlumnoInternoForm and update the AlumnoInternoForm's
> values in order to show the data. :-D
>
> How to do that? Someone?
>
> Software:
>        Symfony: 1.4.6
>        PHP: 5.3.2
>
> Thank you.
>
> --
> If you want to report a vulnerability issue on symfony, please send it to
> security at symfony-project.com
>
> You received this message because you are subscribed to the Google
> Groups "symfony users" group.
> To post to this group, send email to symfony-users@googlegroups.com
> To unsubscribe from this group, send email to
> symfony-users+unsubscr...@googlegroups.com<symfony-users%2bunsubscr...@googlegroups.com>
> For more options, visit this group at
> http://groups.google.com/group/symfony-users?hl=en
>

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en

Reply via email to