2
考慮在線簡歷的情況。zend框架 - 子表單中的表單的組元素
會有一行包含每條教育線和每條體驗線的一些輸入文本。
我想分組教育行中的每個字段和子表單中的經驗行。
然後,這些行的總數也將分組在教育和經驗。
的想法是有一個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?
檢查以及displayGroups獲得字段的字段集(默認情況下)。 – regilero 2011-04-12 15:24:05