Doctrine 具有列聚合继承性的symfony1枚举

Doctrine 具有列聚合继承性的symfony1枚举,doctrine,symfony-1.4,Doctrine,Symfony 1.4,我有一个配置文件表,为所有用户保存所有配置文件。 我有不同类型的用户,希望每种类型的用户都有不同的选择选项来选择某个字段。 因此,这两种用户类型都可以选择他们想要注册的时间,但是他们有不同的选择-一个可以选择2年,另一个不能选择。 schema.yml如下所示: 用户配置文件: columns: username: type: string(255) notnull: true unique: false inheritance:

我有一个配置文件表,为所有用户保存所有配置文件。 我有不同类型的用户,希望每种类型的用户都有不同的选择选项来选择某个字段。
因此,这两种用户类型都可以选择他们想要注册的时间,但是他们有不同的选择-一个可以选择2年,另一个不能选择。
schema.yml如下所示:

用户配置文件:

columns:
    username:
        type: string(255)
        notnull: true
        unique: false
inheritance:
    type: column_aggregation
    extends: UserProfile
columns:
    register_time:
        type: enum
        values:
            - 6 months
            - 1 year
            - 2 years
            - Other
        default: other
inheritance:
    type: column_aggregation
    extends: UserProfile
columns:
    register_time:
        type: enum
        values:
            - 6 months
            - 1 year
            - Other
        default: other
WriterUserProfile:

columns:
    username:
        type: string(255)
        notnull: true
        unique: false
inheritance:
    type: column_aggregation
    extends: UserProfile
columns:
    register_time:
        type: enum
        values:
            - 6 months
            - 1 year
            - 2 years
            - Other
        default: other
inheritance:
    type: column_aggregation
    extends: UserProfile
columns:
    register_time:
        type: enum
        values:
            - 6 months
            - 1 year
            - Other
        default: other
ReaderUserProfile:

columns:
    username:
        type: string(255)
        notnull: true
        unique: false
inheritance:
    type: column_aggregation
    extends: UserProfile
columns:
    register_time:
        type: enum
        values:
            - 6 months
            - 1 year
            - 2 years
            - Other
        default: other
inheritance:
    type: column_aggregation
    extends: UserProfile
columns:
    register_time:
        type: enum
        values:
            - 6 months
            - 1 year
            - Other
        default: other
由于某些原因,我无法选择“2年”选项-表格中出现“无效”错误。

“2年”和“其他”是否相互吻合,因为它们都是第三个选项?

是否有其他不常见的字段?这一字段不足以导致使用列聚合。无论如何,如果同一字段出现在多个子类中,则该字段应上移,并且字段名称在所有相关类中应是唯一的(在您的示例中为UserProfile、WriterUserProfile、ReaderUserProfile)

您可以在表单中更改选项字段的选项:

$choices = array('0' => 'a', '1' => 'b');
$this->getWidget('register_time')->setOption('choices', $choices);
$this->getValidator('register_time')->setOption('choices', array_keys($choices));

默认值不应该是“其他”而不是“其他”吗?也许吧,但这似乎是可行的。我的问题是“2年”不起作用。