Error messages: delayed rendering with templating

Since `$this->getFailedFields()` returns an empty array if there are none, the if statement isn't really necessary since the foreach below won't happen. `$result` will just remain an empty array.