Simpletest PHP 可编写脚本的浏览器...如何测试提交表单名称中包含 [ ] 的表单(基本上采用数组格式)?
我正在使用 simpletest,php 可编写脚本的浏览器,并尝试测试提交一个数组格式的表单,如下所示:
<input id="password" name="session[password]" value="" type="password">
其他输入名称以“session”开头,所以我必须给出每个名称的全名,但似乎没有当我在 PHP 脚本中这样做时,
$this->setField('session[password]', 'password');
我想知道是否有人知道正确执行此操作的方法,或者我可以将其设置为查看输入的 id,因为这始终是唯一的,就我知道,我什至不明白为什么他们选择名称而不是 ID 作为用于此目的的字段......
非常感谢任何建议。
I am using simpletest, the php scriptable browser and trying to test submit a form that is in array format so its like this:
<input id="password" name="session[password]" value="" type="password">
Other input names start with "session" so I have to give the full name of each but it doesn't seem to work when I do it like this in my PHP script:
$this->setField('session[password]', 'password');
I'm wondering if anyone knows of a way to do this properly, or can I set it to look at the input's id instead, since this is always unique, as far as I know, I don't even understand why they chose name rather than ID as the field to use for this...
Any advice is greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以通过查看
$_POST["session"]["password"]
获取用户提交的值(假设表单方法是“post”,而不是“get”)。您可以使用这个简单的脚本来测试它:
You get the value the user has submitted by looking at
$_POST["session"]["password"]
(assuming the form method was "post", not "get").You can test it with this simple script: