我在编写Symfony 2功能测试时遇到问题,无法设置属于数组的复选框(即多个和扩展的选择小部件)
在里面 文件 这个例子是
$form['registration[interests]']->select(array('symfony', 'cookies'));
但它没有显示哪些html可以使用它并且它不适用于我的。这是我的表格的缩减版本
<form class="proxy" action="/proxy/13/update" method="post" >
<input type="checkbox" id="niwa_pictbundle_proxytype_chronologyControls_1" name="niwa_pictbundle_proxytype[chronologyControls][]" value="1" />
<input type="checkbox" id="niwa_pictbundle_proxytype_chronologyControls_2" name="niwa_pictbundle_proxytype[chronologyControls][]" value="2" />
<input type="checkbox" id="niwa_pictbundle_proxytype_chronologyControls_3" name="niwa_pictbundle_proxytype[chronologyControls][]" value="3" />
</form>
一旦它在那里工作,我将转向手动制作的表格
<input type="checkbox" id="13" name="proxyIDs[]" value="13">
<input type="checkbox" id="14" name="proxyIDs[]" value="14">
<input type="checkbox" id="15" name="proxyIDs[]" value="15">
我尝试过类似的东西
$form = $crawler->selectButton('Save')->form();
$form['niwa_pictbundle_proxytype[chronologyControls]']->select(array('3'));
$form['niwa_pictbundle_proxytype[chronologyControls][]']->select(array('3'));
但第一次失败了 select
正在运行一个非对象,第二个说 Unreachable field ""
。