0

2 つのテーブルがあり、スキーマは次のようになります。

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) admin を使用していますが、これら 3 つのフォームをすべて 1 つにマージすることができません。

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();

私は今本当に立ち往生しています。誰かが私を正しい方向に向けてくれることを願っています。

これら 3 つのフォームを 1 つの管理フォームに統合したいだけです。

4

1 に答える 1

0

validatorErrorSchemaは、フォームフィールドとの関連付けを作成するのに役立つsfValidatorオブジェクトの配列です。それはエラーメッセージ全体ですか?

save()メソッドをオーバーライドするコードを削除します。次のような対応する形式でオブジェクトを埋め込む前に、Propelオブジェクト間の関係を作成する必要があります。

public function configure()
{
    $use_fields = array(........);
    $profile = $this->getObject()->getCustomerProfile();
    // Do you assign profile objects if they don't exist?
    if (!$profile) {
        $profile = new CustomerProfile();
        $profile->setCustomer($this->getObject());
    }
    $profileForm = new CustomerProfileForm($profile);
    $this->embedForm('profile', $profileForm);
    array_push($use_fields, 'profile');


    $info = $this->getObject()->getCustomerInfo();
    // Do you assign info objects if they don't exist?
    if (!$info) {
        $info = new CustomerInfo();
        $info->setCustomer($this->getObject());
    }
    $infoForm = new CustomerInfoForm($info);
    $this->embedForm('info', $infoForm);
    array_push($use_fields, 'info');

    $this->useFields($use_fields);
}
于 2012-12-05T05:43:09.920 に答える