Cactiveform Action Parameter

Well my code is as follows

<?php /** @var BootActiveForm $form */

$form = $this->beginWidget(‘CActiveForm’, array(






	'htmlOptions'=&gt;array('class'=&gt;'form-inline well'),

)); ?>

<div class="control-group"><div class="controls">

<?php echo $form->dropDownList($model, ‘a’, CHtml::listData($a, ‘id’, ‘name’), array(‘prompt’ => ‘’,‘class’=>‘span3’)); ?>

<?php echo $form->dropDownList($model, ‘b’, CHtml::listData($b, ‘id’, ‘name’), array(‘prompt’ => ‘’,)); ?>



<div class="control-group"><div class="controls">

	&lt;?php echo CHtml::submitButton('Save',array('class'=&gt;&quot;btn btn-primary&quot;)); ?&gt;




Well the concept is I wanted to change the Url property.To achieve that feature I did implement the action feature of CActive form .It means that upon submitting the values from the dropdownboxes I have to get the desired grid.All things are working fine,except the url.But the interesting point is reloading the page works for me.I have configured main.php also.SO,there is something wrong with the code.Plzz help

Shouldn’t you refer to Yii::app()->controller->createUrl? As far as I know, CApplication doesn’t have method createUrl. Furthermore, is there a controller named ‘controller’ and a view named ‘view’?


CApplication does have access to the createUrl method.


From what I gather - you’re trying to POST your form to a particular URL with custom a & b params. The question is - have you set $a & $b somewhere.

OR do you just want whatever is typed in the form to be shown in the URL on submit? In that case, change your form method to ‘get’, and it should work.

Regarding your first statement,I am using a single form to collect the inputs a,b and display a grid with the Url parameters a and b.

With reference to your second suggestion,I want to use Post only.

Also,please note that upon reloading the page the desired Url comes.SOo,where is the problem in the first place?

I don’t think it works that way. When the page loads, the action URL is loaded too. At that time, it does not have access to $a & $b (since you said they are created in the form that’s inside it).

The simplest way to do what you’re trying to achieve is using the method GET - that will pass the values to URL when you hit submit. Alternatively, you could use JQuery to edit the action URL whenever the dropdown list value changes.


Will you help it using $_POST.I tried the same but failed

Try triggering this code when the form is submitted:

//Set the basePath - used below

var basePath = '<?php echo Yii::app()->basePath; ?>';

var a = $('#a').val();

var b = $('#b').val();

//Serialize data

var serializedData = "?a="+a+"&b="+b;


Should work.