Currently, I am utilizing the
Symfony\Component\DomCrawler\Crawler
component in order to locate a form that contains a name with various CSS special characters.
<input name="myfield[0].thing">
In my code, I have:
$messageElement = $crawler->filter('input[name=myField[0].thing]');
return $messageElement->attr($attribute);
Unfortunately, this results in an error:
Symfony\Component\CssSelector\Exception\SyntaxErrorException: Expected "]", but found.
Evidently, this issue arises because Symfony's CSS selector uses [ ]
to enclose attributes. If I attempt to escape all special characters like so:
$crawler->filter('input[name=myField\[0\]\.thing]');
I now encounter empty output. How can this be rectified?
Additionally, as a bonus question: Is it feasible to utilize a wildcard instead? It appears that *
is ineffective in my case.