On docs we can read:
public static string link(string $text, mixed $url='#', array $htmlOptions=array ( ))
Question:
I don’t understand what $htmlOptions means here. I don’t understand how to pass from this representation to a real code.
Can anyone please provide an example about how can we generate a link with a class defined.
Something like:
<a href="#" class="hello">link hello</a>
It’s easier than you might think, although Yii’s documentation is perhaps a bit more convoluted than needs to be. However, it does say that
$htmlOptionsisIn essence, whatever key/value pairs you put into the array will come out as HTML attributes¹. So, what you want to do is
¹except the “special” values that the docs refer to, which will not end up rendered in HTML as-is but either modify the way
linkworks slightly, or end up affecting the HTML in other ways.