How to replace one GET var in Yii 1.1.* when using form?

I’ve needed URL with one variable replaced so it wouldn’t be duplicated every request. I’ve came up with this simple solution:

I think it’s lot better than using regular expressions 😉

File: view.php

controller->createUrl( Yii::app()->controller->id . '/' . Yii::app()->controller->action->id, $params );

 * Create form with nedded c param included.
echo TbHtml::beginFormTb(TbHtml::FORM_LAYOUT_INLINE, $url, 'GET', [ 'class' => 'plugin-submit-onchange' ]); 
echo TbHtml::label('Number of items in list:', 'c');
echo TbHtml::dropDownList( 'c', $this->_c, $this->options ); 
echo TbHtml::endForm(); 

Published by

Konrad Fedorczyk

Konrad Fedorczyk

I'm interested in programming and gamedev. I especially luv HTML5 and everything connected to web technologies.

Leave a Reply

Your email address will not be published. Required fields are marked *