Create a form on a static page

Hi again (second post or second newbie question) :D

Using that Yii Blog Demo, I learned how to create a form, and change the controller, model, view, etc.

But now I have a question about where we can create forms. Imagine that in that Yii Blog Demo ( I want to create a form (like the contact form) in a static page like "About".

So, Contact Form is ( have a file "contact.php" inside "site" directory.

But "About" page ( have the file "about.php" inside "site/page" directory.

I tried to put a form inside “about.php” but it tells me “Undefined variable: model”. I’m strugling with this. I tried to move “about.php” to “site” directory (instead site/page) and it worked.

So, why doesn’t it work in “site/page”? Or this (organization) is meant to be like this (and my question does not make sense) and it shouldn’t work in “site/page” (forms shouldn’t work on static pages)? I don’t know if my questions make any sense.

Thanks and sorry for these newbie questions.

David Almeida

The question is that the action contact passes the variable model to the form, but the action for static views don’t (that’s why they are named static… they are always the same).

If you want to display a form, you are forced to implement an action, at least for manage the input.

So, if I understood what you said, if I want a form on About page (this is just an example), I need to "move" the About page file from "site/page" directory to "site" directory, just to the file stop being static?

Yes, that’s it.

The renderer of the statics views will not pass any data to the views, you have to implement an action for it.