0

I'm editing a product and its current properties in a form with embedRelation('ProductProperty'). Everything is good so far. E/R diagram here http://d.pr/1N7R

However, now I want to split up the form and show attribute sets in different AJAX tabs according to its SetID. I still want to have a single 'Save' button, but it is not critical if I need to have multiple. How can I do this?

In my _form.php I'm iterating Sets but I can't seem to get the SetID for the ProductProperty form object. Am I going about this the wrong way?

I'm using symfony 1.4 and Doctrine 1.2. Here is my schema.yml

Product:
  tableName: products
  actAs: 
    Timestampable: ~
    Sluggable:
      unique: true
      fields: [title]
      canUpdate: true
  columns:
    id:
      type: integer
      primary: true
      autoincrement: true
    category_id:
      type: integer
      notnull: true
    sku: 
      type: string(50)
      notnull: true
    title: 
      type: string(150)
      notnull: true
  relations:
    Category:
      foreignType: many
      foreignAlias: Products

Property:
  tableName: properties
  actAs:
    Timestampable: ~
    Sluggable:
      unique: true
      fields: [description]
      canUpdate: true
  columns:
    id:
      type: integer
      primary: true
      autoincrement: true
    set_id:
      type: integer
      notnull: true
    description: 
      type: string(100)
      notnull: true
  relations:
    Set:
      foreignType: many
      foreignAlias: Properties

Set:
  tableName: sets
  actAs:
    Timestampable: ~
  columns:
    id:
      type: integer
      primary: true
      autoincrement: true
    title:
      type: string(100)
      notnull: true

ProductProperty:
  tableName: product_properties
  actAs: 
    Timestampable: ~
  columns:
    product_id: 
      type: integer
      primary: true
    property_id: 
      type: integer
      primary: true
    value: 
      type: text
      notnull: true
  relations:
    Product:
      alias: Product
      foreignType: many
      foreignAlias: ProductProperties
      onDelete: cascade
    Property:
      alias: Property
      foreignType: many
      foreignAlias: PropertyProperties
      onDelete: cascade
Rune
  • 171
  • 1
  • 1
  • 8

1 Answers1

0

I managed to solve this with the help from dustin10 on the #symfony IRC channel (irc.freenode.net). In case anyone else need it, here is the solution:

We added a hidden field in my ProductPropertyForm with the SetID I was trying to retrieve in my form:

$this->setWidget('property_set_id', new sfWidgetFormInputHidden());
$this->setDefault('property_set_id', $this->getObject()->getProperty()->getSetId());
$this->setValidator('property_set_id', new sfValidatorString());

That way I could retrieve the value in my form with:

$eForm['property_set_id']->getValue()

I now have my form separated into multiple tabs with jQuery :) Again, thanks a lot to dustin10 for his help.

Rune
  • 171
  • 1
  • 1
  • 8