1

I have this button in my Yii2 project:

Html::a('label', ['/attributes/index'], ['class'=>'btn btn-primary']) ;

The button is located in the page:

/site/view

Now what I want to do is pass a parameter when this button gets clicked to the attributes/index page from the site/view page.

To be more specific it is the ID that I want to pass of a particular record from a DB I am viewing.

Cheers.

1
  • A quick view into the doc Html::a() tells you that the second parameter is used for URL generation (Url::to()). Commented Mar 24, 2015 at 8:00

1 Answer 1

4

You can pass parameters as key => value pairs after the route:

Html::a('label', ['/attributes/index', 'id' => $id], ['class'=>'btn btn-primary']) ;

See the Yii2 docs: http://www.yiiframework.com/doc-2.0/yii-helpers-baseurl.html#toRoute()-detail

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.