0

Here is yii2 code:

<?php $form = ActiveForm::begin([
    'options' => [
        'id' => 'category_id',
        'class' => 'mws-form wzd-validate']]); ?>
    <?= $form->field($model, 'name') ?>
  <?php ActiveForm::end(); ?>

And output HTML:

<form id="cat_form" class="mws-form wzd-validate" action="/text/backend/web/index.php?r=cat%2Fcreate" method="post">
    <input type="hidden" name="_csrf" value="ZHAzcENzcUI.PEofNCkdNVU7bDslOj4XIUAEFHsDNjUsRVgocUQVCw==">
    <div class="mws-form-row">
        <div class="form-group field-cat-name required">
            <label class="control-label" for="cat-name">Name</label>
            <input type="text" id="cat-name" class="form-control" name="Cat[name]">

            <p class="help-block help-block-error"></p>
        </div>
    </div>
</form>

I want to convert HTML above:

<form id="cat_form" class="mws-form wzd-validate" action="/text/backend/web/index.php?r=cat%2Fcreate" method="post">
    <input type="hidden" name="_csrf" value="ZHAzcENzcUI.PEofNCkdNVU7bDslOj4XIUAEFHsDNjUsRVgocUQVCw==">
    <div id class="mws-form-row">
        <label class="mws-form-label">Name <span class="required">*</span></label>
        <div class="mws-form-item large">
            <input type="text" name="name" class="required" />
        </div>
    </div>
</form>

1 Answer 1

3

Try using template. Something like this:

 $form->field($model, 'name',[
     'template' => '<div id="divid" class="mws-form-row">
                        <label class="mws-form-label">
                            {label}
                            <span class="required">*</span>
                        </label>
                        <div class="mws-form-item large">{input}</div>
                     </div>'
 ]);
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.