Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
要使用 Symfony2 以编程方式在表单中设置值,在创建表单后,我发现以下方式有效:
$form_data = $form->getData(); $form_data['name'] = 'new value'; $form->setData($form_data);
这很尴尬,没有更简单的方法$form->set('name', 'new value');吗?
$form->set('name', 'new value');
$form->get('name')->setData('new value');