简体   繁体   English

Symfony Domcrawler遍历多个表单选择“提交”按钮

[英]Symfony domcrawler iterating through multiple forms select submit button

Using the example table html below I would like help with iterating through each table row, and clicking the display button, for each row with DomCrawler. 使用下面的示例表格html,我希望通过DomCrawler遍历每行表格并单击显示按钮。 I tried filtering using many different criteria such as below but couldn't figure it out. 我尝试使用许多不同的条件(例如以下条件)进行过滤,但无法弄清楚。 The DomCrawler worked fine when there is only one form, but having issues with multiple, per table row. 如果只有一种表单,但是每张表行有多个表单,则DomCrawler可以正常工作。 Any help is greatly appreciated :) 任何帮助是极大的赞赏 :)

$crawler->filter('.posting-row .display')
$form = $crawler->selectButton('display')->form();
$submitResult = $client->submit($form);

I have the following code-pen here which has the example table html I need to iterate through, https://codepen.io/anon/pen/ZmQLEE?editors=1011 我在这里有以下代码笔,其中有我需要遍历的示例表格html, https: //codepen.io/anon/pen/ZmQLEE editors = 1011

try this: 尝试这个:

if($crawler->filter('form')->count()){

$form = $crawler->selectButton('display')->eq(1)->form();
$crawler = $client->submit($form);

}

Greetings! 问候!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM