Skip to content

Instantly share code, notes, and snippets.

@dator-zz
Created December 6, 2010 18:00
Show Gist options
  • Save dator-zz/730648 to your computer and use it in GitHub Desktop.
Save dator-zz/730648 to your computer and use it in GitHub Desktop.
<?php
/* I have to table, one user table and one company table.
An user belongs to a company (and a company has many users) .
In the user form, i have the embed form for company.
*/
class myGuardRegisterForm extends BasesfGuardRegisterForm
{
/**
* @see sfForm
*/
public function configure()
{
unset($this['company_id']);
$companyform = new CompanyForm();
$this->embedForm('company', $companyform);
}
}
/* I would like to, when an user is created,
create a company with the embed form and assign this company to the user saved.
How I can accomplish that the simple ( and the symfonish) way ? Thanks :)
*/
@rande
Copy link

rande commented Dec 6, 2010

$user = new User;
$company = new Company;
$company->setUser($user);

$form = new CompanyUserRegistrationForm($company);

and just embed the user form class.

@dator-zz
Copy link
Author

dator-zz commented Dec 6, 2010

Thanks :) But found an easy way :

class myGuardRegisterForm extends BasesfGuardRegisterForm
 {
      /**
      * @see sfForm
      */
      public function configure()
      {
          unset($this['company_id']);
          $this->embedRelation('Company');
      }
}

just works :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment