Reputation: 2265
I am trying to use renderPartial function and Bootstrap classes.
This is my function in the controller file:
public function actionPrintReport() {
Yii::$app->response->format = 'pdf';
return $this->renderPartial('_myReport', []);
}
This is my _myReport file that is rendered: My own styles works but not the Bootstrap classes.
<div class="box box-warning">
<div class="box-body">
Text
</div>
</div>
But the result doesn't show any Bootstrap class:
I also tried renderAjax but the same result.
Upvotes: 0
Views: 568
Reputation: 41
I was trying to do the same as you, I got the solution.
You just needed to check the struture of main file:
<?php $this->beginPage() ?>
<!DOCTYPE html>
<html lang="<?= Yii::$app->language ?>" class="h-100">
<head>
<meta charset="<?= Yii::$app->charset ?>">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<?php $this->registerCsrfMetaTags() ?>
<title><?= Html::encode($this->title) ?></title>
<?php $this->head() ?>
</head>
<body class="d-flex flex-column h-100">
<?php $this->beginBody() ?>
<div class="container-xl outlined-box p-2 m-1 ">
<div class="row ">
test
</div>
<a href="#" class="btn btn-primary ">asdasd</a>
</div>
<h1>asdasdasd</h1>
<?php $this->endBody() ?>
</body>
</html>
<?php $this->endPage();
frontend\assets\AppAsset::register($this);
Upvotes: 0
Reputation: 3567
Well, that is much the point with the function renderPartial()
Renders a view without applying layout.
This method differs from render() in that it does not apply any layout.
The renderPartial function is often used when you'll render the same block of code several times in one page. What was your expected result here? What are you trying to do?
registerAssets is usually loaded in the main view file (the one that is not not rendered). You should have a look at the main layout file and understand how assets are loaded.
Upvotes: 0