Newbie Question: What is the best way to display a graph generated from user form input?

I am tearing my hair out trying to get the most simple thing to work here. I am new to MVC and yii, so please forgive my idiocy and take pity on me.

I can create forms and CRUD screens using yii. I have successfully created form based file uploads and files updates as well.

Here is what I cannot seem to figure out:

I want to create a form in which the user selects some criteria and based on this criteria, I want to display a chart using flot. I can get the flot chart to work and I can get my form to work, but only if when the user presses the submit button the form disappears and the chart appears. That’s not what I want to happen. I want the chart to appear under the form when the user hits the submit button for the first time and the user to be able to make changes to the form criteria, hit the submit button again and see a new chart based on the altered criteria at that point.

I tried to make the report a partial and use renderPartial in my controller once the submit button is pressed, but the report comes out above the form. Managed to get the functionality I want by putting the form and the report in the same view file but not displaying the report part of the view unless the model validates, but I know this is a very wonky way to get the functionality I want.

I realize that I don’t know what I am doing and am missing something basic. Could someone, anyone, please help me out here?

How does your view code look like?

I’m a newbie, but my approach would be like:


if (data) {




To check if there are any validation errors you can use CModel.hasErrors() method and render graph depending on it’s return value.