Activeform - add link in the label?

Hi.

I have an activeform with the model, I know I can create and render out text with the label() method. But is it possible to somehow embed a link <a> into the label?

Now I have this in two separated lines. But I would like to add the <a> link into the label.


<?= $form->field($model, 'contractAgreed')->checkbox()->label('I have read and agree the Contract.') ?>

<a href="<?= Generate::LinkOfContract() ?>" data-toggle="modal" data-target="#contract">Contract</a>

This can be deleted. I found the solution.

Share it then, to help others.

I’d like to see the solution. I need it too.

Found it too.

You have to specify the label content in the view like this.

<?php echo $form->field($reportIssue , 'tc' , [ 'options' => ['class' => ['custom-switch' , 'pl-3']], 'labelOptions' => ['class' => 'custom-control-label'] ])->checkbox(['checked' => false , 'uncheck' => null])->label(Yii::t('app' , 'By sending this message, you agree with the MedAtlas terms and conditions' , [ 'link' => '/'.Yii::t('app' , 'terms-and-conditions') ])); ?>

Sorry for the format, i’m new here.

Hello. Nice you are here.

You can edit your post (pencil icon) and use the editor’s power on it, specifically </> tool to format your code.

More guidelines: https://forum.yiiframework.com/t/welcome-to-the-yii-framework-forum/8#general-guidelines-2