Creating .rtf Document Using Yii

Hi to all! Let me just say that I’m from Ukraine, so do not judge me harshly for my English.

So, I had a problem: there is a form on the website, it’s submitted by the user, and then entered data must to put in the right place in the .RTF document. Why .RTF? - Because I was advised that this problem can be solved using standard Yee view.

So, here is what I have managed to do:

  1. create a model where the validation rules of a fields are defined (my fields - is $firstname, $surname, $patronymic, $email);

  2. create a controller, which should render a view of form and in some way the field values must be substituted in the place specified in the template .RTF, which in theory should also already be somewhere on localhost… and here I have promlems…

  3. create a simple form using standard Yii View.

Thank you very much in advance! :rolleyes:

Well, RTF is really a textual format. I still don’t understand why you absolutely must have an RTF in the end, but it is certainly possible. Just create a new controller action for that and you’re pretty much settled.

For my purposes, select the format of the document is not so important - important outcome. Proposed for save to the user the document should contain the text of the fields (introduced by him) and the attached image (user’s photo), which must also be inserted in a specific location in the document.

Tell me, please, what should be the document template, where it should be on my computer, and how to link it with the controller?

Once again I apologize for my English :D

And HTML is not sufficient for this task?

There would be little difference to the usual request cycle. Like all templates, it would have to be present on your server. Do not forget to set appropriate http headers for your output. Have you read through the Definite Guide to Yii yet? It’s also available in ukrainian ;)

Perhaps you’re right. HTML can solve this problem, but I have already started using the Yii ​​and I want to understand this technology.

Most recently, managed to create the "likeness" RTF document using standards to partition, but in the future for my needs formatting options will be much more complex and voluminous.

So after some thought and searching the internet, I found an interesting library, which should be suitable for my purposes - PHPRtfLite library

I have a question: how to link a controller action with this library? This lib documentation I’ve read - there is nothing complex, but the problem is the difficulty in controller actions…

That’s my controller:


class ResumeController extends Controller


    public function actionIndex() {

        $model = new ResumeForm;

        if(isset($_POST['ResumeForm'])) {

			$model->attributes = $_POST['ResumeForm'];

            if($model->validate()) {

                $file = $this->renderPartial('rtf', 

                                             array('model'=>$model, 'firstname'=>$model->firstname), true);

                Yii::app()->request->sendFile('FileName.rtf', $file, 'text/rtf', true);



         $this->render('index', array('model'=>$model)); 



, where ‘rtf’ - it’s “rtf document template” (i think so…)

‘index’ - it’s my page with a form.

This controller provides the ability to save that will be specified in view "rtf.php".

So, my question is: "How to link my controller, rtf-document template & PHPRtfLite library?".

I would be very grateful to you if you demonstrate it all by example. Thank you. :rolleyes: