0

製品とその現在のプロパティを、embedRelation('ProductProperty') を使用してフォームで編集しています。これまでのところ、すべてが良好です。E/R ダイアグラムはこちらhttp://d.pr/1N7R

ただし、フォームを分割し、SetID に従って異なる AJAX タブに属性セットを表示したいと考えています。「保存」ボタンは 1 つにしたいのですが、複数ある必要があるかどうかは重要ではありません。これどうやってするの?

私の _form.php でセットを反復していますが、ProductProperty フォーム オブジェクトの SetID を取得できないようです。私はこれについて間違った方法で進んでいますか?

symfony 1.4 と Doctrine 1.2 を使用しています。ここに私の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
4

1 に答える 1

0

#symfony IRC チャンネル (irc.freenode.net) の Dustin10 の助けを借りて、これを解決することができました。他の誰かがそれを必要とする場合の解決策は次のとおりです。

フォームで取得しようとしていた SetID を含む隠しフィールドを ProductPropertyForm に追加しました。

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

そうすれば、フォームの値を次のように取得できます。

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

これで、jQuery を使用してフォームを複数のタブに分割できました :) 繰り返しますが、dustin10 の助けに感謝します。

于 2011-04-05T20:25:20.900 に答える