yii Custom form style to adapt ready-made templates

Requirements: want to use the following style but using yii in the form style will

<? = $ Form-> field ($ model, 'attribute_code') -> textInput () -> label ( 'attribute the code name')>?

With a lot of useless div style and clas, you want to customize the following side Liezi implementation can be achieved by ActiveForm in fieldConfig property, compared to

<?= Html::activeInput('text',$model,'icon', ['class'=>'form-control']);?>

This transformation in which the periphery of adding a lot of div style and reduce the amount of code

 <?php
 $form = ActiveForm::begin([
        'fieldConfig'=>[
            'template'=> "<div class='col-lg-2 col-md-2 col-sm-4 col-xs-5 form-control-label'>{label}</div>\n
                          <div class='col-lg-10 col-md-10 col-sm-8 col-xs-7'><div class='form-group'><div class='form-line'>{input}</div></div></div>\n
                          {hint}\n{error}",
            'labelOptions'=>[],
            'options'=>['class'=>'row clearfix'],
        ],
         'options' => ['onsubmit'=> 'return refactorForm ();'], to false
         'validateOnSubmit' =>defines events form onsubmit form//, // solved when a click will define the submit button the onsubmit event performed twice problem, turn off the frame comes with trigger 
    ]); 
 ?>

 

Guess you like

Origin www.cnblogs.com/zhiguopingtianxia/p/10584375.html