我有两个表,这就是架构的样子:
customer:
id:
username: { type: varchar, size: 50, required: true }
password: { type: varchar, size: 50, required: true }
hash: { type: varchar, size: 50, required: true }
customer_profile:
id: { type: integer, foreignTable: customer, foreignReference: id, primaryKey: true, required: true, onDelete: cascade, onUpdate: cascade}
country: { type: varchar, size: 80, required: true }
state: { type: varchar, size: 80, required: true }
city: { type: varchar, size: 80, required: true }
zip: { type: varchar, size: 80, required: true }
customer_info:
id: { type: integer, foreignTable: customer, foreignReference: id, primaryKey: true, required: true, onDelete: cascade, onUpdate: cascade}
preference: { type: longvarchar }
likes: { type: longvarchar }
我目前正在使用 Symfony 1.4 的(propel orm)管理员,但我无法成功地将所有这三种形式合并为一个。
public function configure()
{
$use_fields = array(........);
$sub_form1 = new CustomerProfileForm($this->getObject()->getCustomerProfile());
$this->embedForm('profile', $sub_form1);
array_push($use_fields, 'profile');
$sub_form1->widgetSchema->setNameFormat('customer_profile[%s]');
$sub_form2 = new CustomerInfoForm($this->getObject()->getCustomerInfo());
$this->embedForm('info', $sub_form2);
array_push($use_fields, 'info');
$sub_form2->widgetSchema->setNameFormat('customer_info[%s]');
$this->useFields($use_fields);
}
public function save($conn = null){
if ($forms === NULL)
{
$forms = $this->getEmbeddedForms();
}
$forms['profile']->getObject()->setId($this->getObject()->getId());
$forms['profile']->save();
$forms['info']->getObject()->setId($this->getObject()->getId());
$forms['info']->save();
$this->getObject()->save();
}
但是我收到此错误:
500 | Internal Server Error | sfValidatorErrorSchema
$this->widgetSchema->setNameFormat('customer_profile[%s]');
$this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);
parent::setup();
我现在真的被困住了。我希望有人能指出我正确的方向。
我只想将这三个表单合并到一个管理表单中。