I have third-party CSS, and I want to use it in a Yii2 ActiveForm.
The problem here is: How should I give the classes to a form field? I tried the following but I am not able to get the desired output.
<div class="checkbox checkbox-success">
<?= $form->field($model, 'is_sold')->checkbox(); ?>
</div>
I also tried the following:
<div class="checkbox">
<?= $form->field($model, 'is_sold')->checkbox(['class'=>'checkbox-success']); ?>
</div>
But it renders the HTML code like this:
<div class="checkbox checkbox-success">
<div class="form-group field-mainads-is_sold has-success">
<input type="hidden" name="MainAds[is_sold]" value="0">
<label>
<input type="checkbox" id="mainads-is_sold" name="MainAds[is_sold]" value="1">
Mark as Sold
</label>
</div>
</div>
And the desired output I want is something like the following:
<div class="checkbox checkbox-success">
<input class="styled styled" id="checkbox10" type="checkbox">
<label for="checkbox10">
This too
</label>
</div>
I have also tried this:
<?= $form->field($model, 'is_sold', ['options' => ['class' => 'checkbox checkbox-success']])->checkbox([] ,false) ?>
But it didn't work as well, and it gave output like below:
<div class="checkbox checkbox-success field-mainads-is_sold has-success">
<label class="control-label" for="mainads-is_sold">Mark as Sold</label>
<input type="hidden" name="MainAds[is_sold]" value="0">
<input type="checkbox" id="mainads-is_sold" name="MainAds[is_sold]" value="1">
</div>
The first checkbox in the below image is what I get if I write the HTML code directly, but I want to do it using an ActiveForm field. The second checkbox in the image is what I get with form field code.

