0

我有一个配置文件表,用于保存所有用户的所有配置文件。我有不同类型的用户,并希望每种类型的用户都有不同的选择选项来选择某个字段。
因此,两种用户类型都可以选择他们想要注册的时间,但有不同的选择——一种可以选择 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

出于某种原因,我无法选择“2 年”选项 - 表格给出了“无效”错误。
“2年”和“其他”是否因为它们都是第三选项而彼此重合?

4

1 回答 1

0

还有其他不常见的领域吗?这一个字段仅不足以导致使用列聚合。无论如何,如果同一个字段出现在多个子类中,则该字段应该向上移动,并且字段名称在所有相关类中应该是唯一的(在您的情况下为 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));
于 2013-06-25T20:11:15.980 回答