Reputation: 577
I need to target "selected" attribute in drop down menu so I can compare if item marked as selected is the item what I need to have selected. Can you help me with methods, what I can use for this ?
<option value="Title" selected>Title</option>
<option value="First Name">First Name</option>
<option value="Middle Name">Middle Name</option>
Thank you :)
Upvotes: 2
Views: 1475
Reputation: 577
I've found an answer finally -
$crawler->filter('option[selected]')->attr('value');
works for me :)
Upvotes: 5
Reputation: 3135
Maybe something like that (not tested)
$target = $crawler->filterXPath('//.../option/@selected')->text();
or
$target = $crawler->filterXPath('//.../option')->attr('selected')->text();
Upvotes: 0