[Help]Including forms to specific loacation.

Recently I joined yii and I realized this framework is perfect for my further projects.

However, there is one issue I am facing and I have seen some others having problems with that aswell.

Including forms to specific location.

General question

I made a certain model and form using gii model and CRUD generator. I would like to use that form what I made which is now located in ?r=email/create in my front page ?r=site/index. How can I do that while following the ideology of yii? What about including multiple forms?

More specific question

I generated an AR model for table ‘email’. After that generated CRUD, controller, create, _form. Using that in ?r=email/create (original location) works perfectly. But after I render it to front-page it displays the form but the form itself does not work – it does not do anything except reloading the page.


$model=new Email; 

$this->renderPartial('//email/_form',array('model'=>$model), false,true); 

What am I missing?

Thanks,

Creator_M

I suppose that in the _form.php a form is created using CActiveForm…

Check the action property - http://www.yiiframew…m#action-detail

By default it uses the current URL and in your case it’s site/index…

So you need to process the form in your SiteController->actionIndex()…

or set another action in the form…

Oh yeah that makes sence.

Thank you very much for helping out.

Change the form Header like this…





<?php

 $form=$this->beginWidget('CActiveForm', array(

	'id'=>'email-form',

	'action'=>'index.php?r=email/_form',

	'enableAjaxValidation'=>false,

)); ?>









Set ‘action’ to email/_form or create another controller action to do the things with email/_form.