2010/1/8 Benoit Montuelle <[email protected]> > Hi list, > > I am working with symfony 1.4 to build a simple registration form, I got 2 > models for this part : Registration and Person, which works with standalone > generated modules. > > The registration model has 2 one to one relations with person for recording > 2 contact information (respectively named Participant and Contact). I want > to bring both contact informaiton in the same form, tied to registration > form in registration module. Altough registration records cannot be modified > directly in form, it has to be timestampped and update status once the form > user has registered. > > I defined my form class like with this only method : > class FrontEndRegistrationForm extends BaseRegistrationForm > { > public function configure() > { > //delete everything > $this->setWidgets(array()); > $this->setValidatorSchema(new sfValidatorSchema()); > > //adding 2 persons forms > $participant = $this->getObject()->getParticipantPerson(); > $this->embedForm("participant", new > ParticipantPersonForm($participant)); > > $contact = $this->getObject()->getContactPerson(); > $this->embedForm("contact", new ContactPersonForm($contact)); > } > } > > ParticipantPersonForm and ContactPersonForm are both derivating from > BasePersonForm and aim to remove different unused fields. > > > My problem is the embeded forms are both named with the model name, which > is the same in this case (Person) . I though the first argument of the > embedForm method was use to prefix fields name in HTML rendering, but > apparently not. > > Also, I tried adding in my sub-forms configure method the statement > > $this->setOption('name_format', 'participant[%s]'); > > And $this->setOption('name_format', 'contact[%s]'); > > Nothing to do, I am stuck with field named contact[%s] and unable to > properly save forms data. > In my view file, I dumped the form vars and checked them, they seem ok for > widgets/validators and using the right classes (ParticipantPersonForm & > ContactPersonForm) But both have the default option for 'name_format' > whatever I tried. > > Did I do something wrong in the implementation ? > Is there any other way to get this working ? > > Best regards, > Benoit > >
To be precise, I need my form to be edited by designers, so almost all HTML
accessible in the view file.
In my view I had
$participantForm = $form->getEmbeddedForm('participant');
and rendering fields labels and errrors with :
echo $participantForm['first_name']->renderLabel();
echo $participantForm['first_name']->renderError();
echo $participantForm['first_name'];
But I just tried a simple "echo $form" to render the whole form at once and
this time, fields name are the correct ones.
I think of a problem with configuration order, or name collision when using
$form->getEmbeddedForm method
thank you
-- You received this message because you are subscribed to the Google Groups "symfony users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to [email protected].
For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en.
