Renan
Renan

Reputation: 1

Yii render view in another view

I have a rendered view in my application and when I export to PDF I'd like to use the data that I rendered before. Now I'm using another way to do it, I load all things again to export. How can I do it?

I've used this code but don't had success:

array('label'=>'Export pdf', 'url'=>array($this->renderPartial(
      'ViewPDF2', array('sessao' => $GLOBALS['session'],'name_project'=>$model->name_project,'id_project'=>$model->i‌d_project,'dataStart'=>$model->data_start,'dataEnd'=>$model->data_end))))

Upvotes: 0

Views: 6779

Answers (2)

shgnInc
shgnInc

Reputation: 2196

In url parameter you should use an URL Address which refer to an action which that action render the view that exporting to PDF. The renderPartial method just render a view file in your self layout format.

Upvotes: 0

ernie
ernie

Reputation: 6356

I'm not sure how you've got that code in your view? You're passing that array as an argument to some function? All we can see right now is you're defining an array.

The general approach for rendering a view within in a view would be something like this (this is the container view file):

<?php //view code here ?>
<!-- some html in your view-->
<div id='included_view' >    
  <?php $this->renderPartial('viewName', array('argForView'=>$foo)); ?>
</div>

<!-- rest of view -->

Note that the use of $foo there means that you previously passed that variable to the container view (or that you defined $foo in a PHP code block before the renderPartial)

Upvotes: 2

Related Questions