Prabhakaran
Prabhakaran

Reputation: 60

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 :-((((

Upvotes: 0

Views: 45

Answers (1)

dataskills
dataskills

Reputation: 656

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]);

Upvotes: 1

Related Questions