Jon,
  Thanks for the quick reply.
  With my knowledge of Doctrine, that's what I assumed the first error
which is why I had tried Email[] and I had tried Email[0] before that
as well.  When I tried your code I get the same problem as with just
Email[]
{{{
Unexpected extra form field named "Email".
}}}

This is what lead me to believe that it might be a problem I'm having
with symfony and not just Doctrine in symfony.

If it helps here is the outputted form:
{{{
#!html
 <label for="user_first_name">First name</label>
  <input type="text" name="user[first_name]" id="user_first_name" />
</li>
<li>
  <label for="user_last_name">Last name</label>
  <input type="text" name="user[last_name]" id="user_last_name" />
</li>
<li>
  Email[0]
  <table>

  <tr>
  <th><label for="user_Email_0_user_id">User id</label></th>
  <td><select name="user[Email][0][user_id]"
id="user_Email_0_user_id">
<option value="" selected="selected"></option>
<option value="1">1</option>
<option value="2">2</option>
</select></td>
</tr>
<tr>
  <th><label for="user_Email_0_address">Address</label></th>

  <td><input type="text" name="user[Email][0][address]"
id="user_Email_0_address" /><input type="hidden" name="user[Email][0]
[id]" id="user_Email_0_id" /></td>
</tr>
</table>
</li>
<li>
  Email[1]
  <table>
  <tr>
  <th><label for="user_Email_1_user_id">User id</label></th>
  <td><select name="user[Email][1][user_id]"
id="user_Email_1_user_id">
<option value="" selected="selected"></option>

<option value="1">1</option>
<option value="2">2</option>
</select></td>
</tr>
<tr>
  <th><label for="user_Email_1_address">Address</label></th>
  <td><input type="text" name="user[Email][1][address]"
id="user_Email_1_address" /><input type="hidden" name="user[Email][1]
[id]" id="user_Email_1_id" /></td>
</tr>
</table>
<input type="hidden" name="user[id]" id="user_id" /></li>
}}}

-- Stephen Ostrow <[EMAIL PROTECTED]>

On Nov 11, 9:55 am, "Jonathan Wage" <[EMAIL PROTECTED]> wrote:
> Well, you get that error because when you embed it with a name of Email, it
> tries to set something to a Doctrine record which is a collection, and you
> are passing it a single piece of data.
>
> Try:
>
> for ($i = 0; $i < 5; $i++)
> {
>    $form->embedForm('Email[' . $i . ']', new EmailForm());
>
> }
>
> On Tue, Nov 11, 2008 at 2:09 AM, isleshocky77 <[EMAIL PROTECTED]>wrote:
>
>
>
>
>
> > Ok, I've been trying to get this to work properly for a few days now
> > and have made a little progress but cannot get this to fully work.
>
> > So My model looks something like this:
> > {{{
> > #!yaml
> > User:
> >  columns:
> >    first_name: string(255)
> >    last_name: string(255)
>
> > Email:
> >  columns:
> >    user_id:  integer
> >    address: string(255)
> >  relations:
> >    User:
> > }}}
>
> > I'm embedding the form in the action just for ease of testing this
> > before I put it in the form class.
>
> > My Action:
> > {{{
> > #!php
> >  public function executeIndex(sfWebRequest $request)
> >  {
> >    $this->form = new UserForm();
> >    $email_form = new EmailForm();
>
> >    $this->form->embedForm('Email', $email_form);
>
> >    if ($request->isMethod('post'))
> >    {
>
> >      $this->form->bind($request->getParameter('user'));
> >      if ($this->form->isValid())
> >      {
> >        $this->form->save();
> >      }
> >    }
> >  }
> > }}}
>
> > When I try to submit the form I get an error:
> > {{{
> > Catchable fatal error: Argument 1 passed to
> > Doctrine_Record::fromArray() must be an array, string given, called
> > in /srv/symfony/branches/1.2/lib/plugins/sfDoctrinePlugin/lib/doctrine/
> > Doctrine/Collection.php on line 702 and defined in /srv/symfony/
> > branches/1.2/lib/plugins/sfDoctrinePlugin/lib/doctrine/Doctrine/
> > Record.php on line 1506
> > }}}
>
> > When I change the embedForm('Email', $email_form) to
> > embedForm('email', $email_form) then the form submits without error,
> > but doesn't save the email address.
>
> > I would preferably like it like this:
> > embedForm('Email[], $email_form);
> > This way I can have multiple Email Addresses on this one form.  When I
> > do this it displays correctly but when I go to submit it fails
> > validation with the following output:
> > {{{
> > Unexpected extra form field named "Email".
> > }}}
>
> > I'm thinking there has to be some way to link the Email's user_id to
> > the new user, but I'm not sure of the proper way to do this.
>
> > Thanks in advance for any help.
>
> > --
> > Stephen Ostrow <[EMAIL PROTECTED]>
>
> --
> Jonathan H. Wage
> Open Source Software Developer & 
> Evangelisthttp://www.jwage.comhttp://www.doctrine-project.orghttp://www.symfony-project.org
--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to