Код: Выделить всё
<?= $type = $form->field($model, 'type')->dropDownList([
'string' => 'string',
'image' => 'image',
]) ?>
<?
$file = $form->field($model, 'file')->fileInput();
$value = $form->field($model, 'value')->textInput();
?>
Код: Выделить всё
$script = <<< JS
$($type).on('change',function(){
var selection = $(this).val();
switch(selection){
case $value:
$($value).show()
$($file).hide()
break;
case $file:
$($file).show()
$($value).hide()
break;
default:
$($value).hide()
}
});
JS;