We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4ea851d commit a2f361cCopy full SHA for a2f361c
components/dom_crawler.rst
@@ -238,6 +238,18 @@ Access the attribute value of the first node of the current selection::
238
239
$class = $crawler->filterXPath('//body/p')->attr('class');
240
241
+.. tip::
242
+
243
+ You can define the default value to use if the node or attribute is empty
244
+ by using the second argument of the ``attr()`` method::
245
246
+ $class = $crawler->filterXPath('//body/p')->attr('class', 'my-default-class');
247
248
+ .. versionadded:: 6.4
249
250
+ The possibility to specify a default value to the ``attr()`` method
251
+ was introduced in Symfony 6.4.
252
253
Extract attribute and/or node values from the list of nodes::
254
255
$attributes = $crawler
0 commit comments