【发布时间】:2011-09-24 08:34:15
【问题描述】:
【问题讨论】:
标签: symfony
【问题讨论】:
标签: symfony
如果保险选择是用户的已知值,那么您可以在创建表单时将它们作为选项传递:
$form = $this->createForm(new AgentContractFormType(), $agentContract, array(
'insurances' => array(/* insurance choices here */),
));
然后在你的表单类中:
public function getDefaultOptions(array $options)
{
return array(
'insurances' => $options['insurances'],
'data_class' => 'NTO\DocumentBundle\Entity\Document\AgentContract',
);
}
然后您可以随意在buildForm() 中使用它们。希望对您有所帮助。
【讨论】: