Symfony1 Symfony sfWidgetFormDoctrineChoice与';多重'=&燃气轮机;真的

Symfony1 Symfony sfWidgetFormDoctrineChoice与';多重'=&燃气轮机;真的,symfony1,doctrine,symfony-1.4,symfony-forms,Symfony1,Doctrine,Symfony 1.4,Symfony Forms,我将symfony 1.4.11与条令一起使用。因此,模式的一部分: Companies: actAs: Timestampable: ~ Sluggable: unique: true fields: [company] canUpdate: false builder: [myTools, StripText] connection: doctrine tableName: companies columns:

我将symfony 1.4.11与条令一起使用。因此,模式的一部分:

Companies:
  actAs:
    Timestampable: ~
    Sluggable:
      unique: true
      fields: [company]
      canUpdate: false
      builder: [myTools, StripText]
  connection: doctrine
  tableName: companies
  columns:
    company_id:       { type: integer(4), primary: true, notnull: true, autoincrement: true }
    user_id:          { type: int(4)  }
    category_id:      { type: int(4), notnull: true  }
    company:          { type: string(255), notnull: true  }
    address:          { type: string(255), notnull: true  }
    contact_person:   { type: string(255), notnull: true  }
    phone:            { type: string(50), notnull: true }
    fax:              { type: string(50) }
    email:            { type: string(255), notnull: true}
    url:              { type: string(50) }
    about:            { type: string(1000), notnull: true}
    country:          { type: string(255), notnull: true}
    show_ads:         { type: boolean, default: 0 }
    active:           { type: boolean, default: 0 }
    has_company:      { type: boolean, default: 1 }
  relations:
    Owner:            { onDelete: CASCADE, local: user_id, foreign: id, class: sfGuardUser, foreignAlias: Companies }
    Images_companies: { local: company_id, foreign: company_id, type: many, class: Images_companies }
    Categories:       { onDelete: CASCADE, local: category_id, foreign: category_id , type: many, foreignType: one}

Categories:
  actAs:
    I18n:
      fields: [name]
      actAs:
        Sluggable:
          unique: true
          fields: [name]
          canUpdate: true
          builder: [myTools, StripText]
    NestedSet:
      hasManyRoots: true
  connection: doctrine
  tableName: categories
  columns:
    category_id:   { type: integer(4), primary: true, autoincrement: true }
    name:            string(255)
我希望用户可以为公司选择多个类别。我使用sfWidgetFormDoctrineChoice,所以当我

$this->widgetSchema['category_id'] = new  sfWidgetFormDoctrineChoice(array('model' => 'Categories', 'add_empty' => false, 'multiple' => false));
用户只能选择一个类别,一切正常。 当我有:

$this->widgetSchema['category_id'] = new  sfWidgetFormDoctrineChoice(array('model' => 'Categories', 'add_empty' => false, 'multiple' => true));
在db save category_id=0中,从列表中仅选择一个类别。当我选择多个类别时,出现错误: SQLSTATE[HY093]:无效参数编号:绑定变量的数量与令牌的数量不匹配


我在谷歌搜索这个错误,但我没有找到决定,我现在也不知道我哪里做错了什么。谢谢大家!

您定义关系的方式不允许您为公司选择多个类别。您可能需要设置多对多关系。

您定义关系的方式不允许您为公司选择多个类别。您可能需要设置多对多关系。
在我的情况下,我必须修改验证器:

$this->validatorSchema[idapplication] = new sfValidatorDoctrineChoice(
    array(
        model=>'hotteApplication', 'multiple' => true
    )
);

在我的情况下,我必须修改验证器:

$this->validatorSchema[idapplication] = new sfValidatorDoctrineChoice(
    array(
        model=>'hotteApplication', 'multiple' => true
    )
);

非常感谢。我更改类别:
{onDelete:CASCADE,local:category\u id,foreign:category\u id,type:many,foreignType:many}
,但我仍然有错误…谢谢!我更改类别:
{onDelete:CASCADE,local:category\u id,foreign:category\u id,type:many,foreignType:many}
,但我仍然有错误。。。