Render A Form In A Static Page

Hello !

I have a big issue trying to call a partialRender of a form in a static page in views/site/page/register.php

$model=User::model();

$this->renderPartial(’//User/_form’,array(‘model’=>$model));

The form is well displayed but when I submit the form, it doesn’t happen anything : it redirects to the same page. I want my form to be validated, to display the errors if there are some and to create my new user.

How can I do this ?? Have I to call the ‘actionCreate’ of my UserController ? How ?

I’m lost with Yii, definitely.

Thanks in advance & have a nice day !

maybe you should provide ‘action’ where the form will redirect after submission?

paste snippet of your php code where you render your form…

It begins with :




<div class="form">

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

	'id'=>'user-form',

	'enableAjaxValidation'=>false,

));

?>



Like every auto-generated form.

Have I to add an ‘action’=>’…’ in the array ?

And what parameter ?

In fact, I want to display my form in a different page and directory than the auto-generated create.php view.

I thought it was possible but maybe it’s not …

Please provide code responsible for your form action parameter.

There’s no action parameter… it’s automatic for the generated form. and when i try to specify action=’…’ it doesn’t change anything.

in fact there is ‘action’ parameter: http://www.yiiframework.com/doc/api/1.1/CActiveForm#action-detail




<div class="form">

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

        'id'=>'user-form',

        'enableAjaxValidation'=>false,

        'action'=>array( 'controller/action' ),

));

?>



it should change target action where form data is submitted.

Oh ok ! It works !

with the parameter ‘action’=>Yii::app()->createUrl(’//user/create’)

Thanks :)