As adamS and Michiel have commented, if you want to put a form or data in your main.php layout file, you should use a widget.
To create a widget, you need to do the following:
1: Create a php file in your /protected/components/
dir, something like SubscriptionWidget.php
2: Create a dir views
in your components dir
3: Create your view .php file in your /protected/components/views/
, something like subscriptionWidget.php
4: Put the following code in your SubscriptionWidget.php
file:
<?php
class SubscriptionWidget extends CWidget
{
public function init()
{
}
public function run()
{
$model = new SubscriptionForm;
if(isset($_POST['SubscriptionForm']))
{
// proces the data
}
$this->render('subscriptionWidget', array('model'=>$model));
}
}
?>
Your widget is done. All you need to do now is call it in your main.php
layout file, like so:
<!doctype html>
<html lang="en">
...
<?php $this->widget('SubscriptionWidget'); ?>
...
</html>
Also, don't forget to put the form in your newly created view file.
Hope this helps.