projet01
(Projet)
December 14, 2012, 8:52am
1
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 !
redguy
(Maciej Lizewski)
December 14, 2012, 9:03am
2
maybe you should provide ‘action’ where the form will redirect after submission?
paste snippet of your php code where you render your form…
projet01
(Projet)
December 14, 2012, 9:10am
3
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 ?
projet01
(Projet)
December 14, 2012, 9:13am
4
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 …
LastDay
(Egorsmir)
December 14, 2012, 3:26pm
5
Please provide code responsible for your form action parameter.
projet01
(Projet)
December 17, 2012, 4:33pm
6
There’s no action parameter… it’s automatic for the generated form. and when i try to specify action=’…’ it doesn’t change anything.
redguy
(Maciej Lizewski)
December 17, 2012, 8:14pm
7
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.
projet01
(Projet)
December 18, 2012, 9:41am
8
Oh ok ! It works !
with the parameter ‘action’=>Yii::app()->createUrl(’//user/create’)
Thanks