小编Jan*_*lka的帖子

使用ajax在yii2中向表单添加更多字段

我有一个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)

根据选定的下拉值,我必须在同一模型的相同形式中添加更多字段.将添加哪些字段完全取决于下拉值.

我怎样才能做到这一点?

php ajax yii2

13
推荐指数
1
解决办法
3498
查看次数

在 Powershell 5.0 类中使用自定义类型

这是目前让我头疼的示例代码。

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.

如果我执行 …

powershell powershell-5.0

1
推荐指数
1
解决办法
1725
查看次数

标签 统计

ajax ×1

php ×1

powershell ×1

powershell-5.0 ×1

yii2 ×1