This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use the new forum.
Home » support » symfony 1.3 and 1.4 » Symfony one-to-many embedrelation showing multiple forms
Symfony one-to-many embedrelation showing multiple forms [message #102163] Thu, 08 July 2010 03:22 Go to next message
piwh1000  is currently offline piwh1000
Messages: 1
Registered: July 2010
Junior Member
I'm having what should be a simple problem with Symfony.

In this example I have a User, LookingFor, and LookingForNames table. The user table holds the user account and has a relation with LookingFor. The LookingFor table holds any relations between a user and the LookingForNames.

Example: The user 'chain', could have two entries in the LookingFor table for dating and talk, which are looked up from the LookingForNames table based on the type_id from LookingFor and LookingForNames.

The problem I am having is when I embedRelation for LookingFor within the User form. It's showing the LookingFor form twice because the user has selected they are looking for dating and talk. It would show up more times if I have more selected for that user.

eg. of the problem

LookingFor Form - Instance #1
Dating - Checked
Talk - Not Checked
Friends - Not Checked

LookingFor Form - Instance #2
Dating - Not Checked
Talk - Checked
Friends - Not Checked


The solution would be showing the LookingFor table once in a checkbox format where the user's selection would be preselected.

eg. of the solution

LookingFor Form - Only One Instance
Dating - Checked
Talk - Checked
Friends - Not Checked


schema.yml

LookingFor:
  connection: doctrine
  tableName: looking_for
  columns:
    type_id:
      type: integer(4)
      fixed: false
      unsigned: false
      primary: true
      autoincrement: false
    uid:
      type: integer(4)
      fixed: false
      unsigned: false
      primary: true
      autoincrement: false
  relations:
    LookingForNames:
      local: type_id
      foreign: type_id
      type: many
LookingForNames:
  connection: doctrine
  tableName: looking_for_names
  columns:
    type_id:
      type: integer(4)
      fixed: false
      unsigned: false
      primary: true
      autoincrement: true
    name:
      type: string(255)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
  relations:
    LookingFor:
      local: type_id
      foreign: type_id
      type: many
User:
  connection: doctrine
  tableName: user
  columns:
    id:
      type: integer(4)
      fixed: false
      unsigned: false
      primary: true
      autoincrement: true
    email:
      type: string(255)
      fixed: false
      unsigned: false
      primary: false
      notnull: false
      autoincrement: false
    gender:
      type: string(6)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
    age:
      type: date(25)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
    city:
      type: string(255)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
    state:
      type: string(255)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
    country:
      type: integer(4)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
    profilepic:
      type: string(255)
      fixed: false
      unsigned: false
      primary: false
      default: profileblank.jpg
      notnull: false
      autoincrement: false
  relations:
    LookingFor:
      local: id
      foreign: uid
      type: many
      foreignType: many


UserEditForm

class UserEditForm extends BaseUserForm
{
  public function configure()
  {
            $this->embedRelation('LookingFor');
  }
}


LookingForForm

class LookingForForm extends BaseLookingForForm
{
  public function configure()
  {
      $this->useFields(array('type_id'));
      $this->widgetSchema['type_id'] = new sfWidgetFormChoice(array(
          'choices' => Doctrine_Core::getTable('LookingForNames')->getFormChoiceNames(),
          'expanded' => true,
          'multiple' => true
       ));
   }
}

Re: Symfony one-to-many embedrelation showing multiple forms [message #103152 is a reply to message #102163 ] Tue, 27 July 2010 23:47 Go to previous message
pr0gram0r  is currently offline pr0gram0r
Messages: 1
Registered: July 2010
Location: Montréal
Junior Member
I Have a similar problem, hope some one point in some direction.

Cheers !

pr0g
Previous Topic:sfSessionStorage reading old cookie!!!!
Next Topic:Problem with build schema
Goto Forum:
  

powered by FUDforum - copyright ©2001-2004 FUD Forum Bulletin Board Software