You're trying to register a file after View::endPage() has been called

I’m struggling since having tried to implement RowVersion column in Azure which Yii can’t support. So I rolled back my db changes but keep getting the error:

You’re trying to register a file after View::endPage() has been called

which point to the following in my controller:

'modelsDriversCertifications' => (empty($modelsDriversCertifications)) ? [new EmployeesDriversCertifications] : $modelsDriversCertifications

which is a line that has worked for years without issue. So I’m pretty sure the log is not accurate in this instance.

I’ve already run

Yii::$app->db->schema->refresh();

and validated the table schema is accurate. The RowVersion column is no longer listed.

But, I can’t figure out the true origins of the current error message. Any advice is greatly appreciated.

Should I be flushing the entire cache?

Yii::$app->cache->flush();

This warning pops up when you are trying to register JS or CSS file after the page has been generated (see here). You need to check which of your files is trying to register something at this point (when it should not). It was introduced in 2.0.44.

1 Like

Thank you for the link. Any chance you could enlighten me as to what I’m looking for exactly.

I put back in place an old version of the View file and now the error is gone. I’ve compared the 2 files (good vs bad) and truly don’t see any changes in registering files.

both files have a single

$this->registerJS($script);

which is the last line of the view. That’s it. Is there something else I should be looking for? Why does the error flag the Controller when it’s the view that’s at fault?

Would having changed a section of code from

echo $this->render(

to

echo $this->renderAjax(

be the cause? It 's the only other thing standing out.

After more testing it is indeed because of the

echo $this->renderAjax(

1 Like