FormErrorIterator::count()

int count()

Returns the number of elements in the iterator.

Note that this is not the total number of errors, if the constructor parameter $deep was set to true! In that case, you should wrap the iterator into a {@link \RecursiveIteratorIterator} with the standard mode {@link \RecursiveIteratorIterator::LEAVES_ONLY} and count the result.

$iterator = new \RecursiveIteratorIterator($form->getErrors(true));
$count = count(iterator_to_array($iterator));

Alternatively, set the constructor argument $flatten to true as well.

$count = count($form->getErrors(true, true));

Return Value

int The number of iterated elements
doc_Symfony
2016-10-28 06:18:29
Comments
Leave a Comment

Please login to continue.