2

オンライン履歴書の場合を考えてみましょう。

各教育ラインと各経験ラインのいくつかの入力テキストを含む行があります。

各フィールドを教育ラインでグループ化し、サブフォームで経験ラインをグループ化したいと考えています。

次に、これらの行の合計も教育と経験にグループ化されます。

アイデアは、次のような 3 次元配列を持つことです。

[experience][0][company]
[experience][0][from]
[experience][0][current]
[experience][1][company]
[experience][1][from]
[experience][1][until]

[education][0][institution]
[education][0][from]
[education][0][until]
[education][0][graduated]

Zendフレームワークを使用したサブフォームについて多くのことを読みました。入力要素がサブフォームに属していることをどこで確認できるかを理解できませんでした。

私がこれまでに得たものはこれです:

public function init()
{
    $this->setMethod('post');

    $this->addElement('text', 'CvName', array(
        'label'     =>'CV Name:',
        'required'  => true,
        'validator' => 'alnum'
    ));

    $this->addElement('text', 'UserID', array(
        'label'     =>'UserID:',
        'required'  => true,
        'validator' => 'alnum'
    )); //I'm still just testing so userid is a field 

    //Now I want the experience fields here
    $this->addSubForm('experience');

    //How do I tell my element 'Company' that it belongs to the subform 'experience'?
    $this->addElement('text', 'Company', array(
        'label'     =>'Company:',
        'required'  => true,
        'validator' => 'alnum'
    ));

    $this->addElement('submit', 'submit', array(
        'ignore'    => true,
        'label'     => 'Save CV'
    ));
}

サブフォーム「経験」に属していることを要素「会社」に伝えるにはどうすればよいですか?

また、addSubForm または addSubForms を使用する必要がありますか?

4

0 に答える 0