Q:

Changing Url method in YII2

My url is in yii2:
$component_id = '175';
$used = '1';
Yii::$app->UrlManager->createUrl('component/datafield&c_id='.$component_id. '&value='.$used);

Its runs  :
index.php?r=component%2Fdatafield%26c_id%3D176%26value%3D1

it shows page not found :-((((

A:

This is an example from the Yii2 guide (http://www.yiiframework.com/doc-2.0/guide-runtime-routing.html#routing-and-url-creation):
use yii\helpers\Url;

// Url::to() calls UrlManager::createUrl() to create a URL
$url = Url::to(['post/view', 'id' => 100]);

Assuming you have "ComponentController" with action "actionDataField":
$url = Url::to(['component/datafield','c_id'=>$component_id,'value'=>$used]);

