我有一个配置文件表,保存所有用户的所有配置文件。我有不同类型的用户,并希望每种类型的用户有不同的选择选项来选择某个字段。
因此,这两种用户类型都可以选择他们想要注册的时间长度,但有不同的选项-一个可以选择2年,另一个不能。
schema.yml如下所示:
UserProfile:
columns:
username:
type: string(255)
notnull: true
unique: falseWriterUserProfile:
inheritance:
type: column_aggregation
extends: UserProfile
columns:
register_time:
type: enum
values:
- 6 months
- 1 year
- 2 years
- Other
default: otherReaderUserProfile:
inheritance:
type: column_aggregation
extends: UserProfile
columns:
register_time:
type: enum
values:
- 6 months
- 1 year
- Other
default: other由于某些原因,我无法选择“2年”选项-表单给出了一个“无效”错误。
“两年”和“其他”是不是因为它们都是第三种选择而相互重合?
发布于 2013-06-26 04:11:16
是否有其他不常见的字段?这一个字段不足以导致使用列聚合。无论如何,如果相同的字段出现在多个子类中,那么字段应该向上移动,并且字段名称在所有相关的类中都应该是唯一的(在您的例子中是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));https://stackoverflow.com/questions/17296308
复制相似问题