<div id="show_field" class="show-field hidden"> - скрытый блок
<div class="col-lg-6">
<?= $form->field($model, 'square')->textInput() ?>
</div>
</div>
$('#id').on('change', function () {
$.ajax({
...
success: function (data) {
var id = "";
data2 = JSON.parse(data, function (key, value) {
if (key == 'id') {
id = "#"+value;
} else {
console.log(id + '=' + value);
if (value) {
$(id).removeClass('hidden')
} else {
$(id).addClass('hidden');
}
}
});
}
});
});
class ProductController extends Controller
{
public $searchModel;
public function init()
{
$this->searchModel = new ProductSearchModel();
}
}
<div class="container">
<?= $this->render('@app/views/product/_search', ['model' => Yii::$app->controller->searchModel]); ?>
</div>