我有一个Yii2 form:
<?php $form = ActiveForm::begin(['id' => 'que']); ?>
<?php echo $form->field($model, 'type')
->dropDownList($questionTypes, [
'class' => 'form-control ng-pristine ng-valid ng-touched',
'prompt' => 'Select question type',
'ng-model' => 'que.type',
'ng-change' => 'addAnswerOptions(que);',
]);
?>
<?php ActiveForm::end(); ?>
Run Code Online (Sandbox Code Playgroud)
根据选定的下拉值,我必须在同一模型的相同形式中添加更多字段.将添加哪些字段完全取决于下拉值.
我怎样才能做到这一点?
这是目前让我头疼的示例代码。
if (("Win32.NativeMethods" -as [type]) -eq $null){
Add-Type -MemberDefinition '[DllImport("user32.dll")] public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow);
' -name NativeMethods -namespace Win32
}
class AppInstance
{
[string]$App = 'Notepad.exe'
[IntPtr]$hWnd = 0
[System.Object]$process
AppInstance () {
Start-Process $this.App
$this.process = get-process ($this.App.split('.'))[0]
start-sleep -Milliseconds 100
$this.hWnd = $this.process.MainWindowHandle
}
[void] Show () {
[Win32.NativeMethods]::ShowWindowAsync($this.hWnd, 3)
}
[void] Hide () {
[Win32.NativeMethods]::ShowWindowAsync($this.hWnd, 2)
}
}
Run Code Online (Sandbox Code Playgroud)
这个类可以像这样使用
$notepad = [AppInstance]::new()
$notepad.Hide()
$notepad.Show()
Run Code Online (Sandbox Code Playgroud)
基本上,我想要做的是从 user32.dllas 类型[Win32.NativeMethods],然后在class.
如果我执行 …