我在php / yii2中搜索我的问题的解决方案。我正在使用DependDropdown小部件。
指导:我目前正在工作(假设'应用程序')表格有列:
1. Id
2. student_id
3. university_id [....rest....]
在我的ActiveForm中,我有一个下拉列表,让我们说学生的名字。它们被分组在模型中,但是如果有相同姓名和姓氏的学生,我想添加Depend Dropdown with Personal Identify Number来选择特定的人。但是具有此数字的列来自另一个表,而不是我的$model
。应用程序表有student_id
列,我希望将该student_id发送到ActiveForm,但是通过我的Dropdown用个人ID搜索它。我试着在示例中显示它
<droplist with names >
我选择例如Carl Dickens
<droplist with Personal number>
案例1:好的,在DB学生表中只有1个Carl Dickens。所以从droplist中只能选择一个数字
案例2: DB中有一些Carls Dickens。所有Carl Dickens的个人号码都会被删除到下拉列表中,所以你可以选择正确的个人号码
<droplist with Personal number>
不是$model
(应用程序)表中的列,这是我在ActiveForm中的问题。有人能帮助我吗?
感谢
答案 0 :(得分:0)
请将$ personal_number声明为模型中的变量
private async void OnSuspending(object sender, SuspendingEventArgs args)
{
suspendDeferral = args.SuspendingOperation.GetDeferral();
rootPage.NotifyUser("", NotifyType.StatusMessage);
using (var session = new ExtendedExecutionSession())
{
session.Reason = ExtendedExecutionReason.SavingData;
session.Description = "Pretending to save data to slow storage.";
session.Revoked += ExtendedExecutionSessionRevoked;
ExtendedExecutionResult result = await session.RequestExtensionAsync();
switch (result)
{
case ExtendedExecutionResult.Allowed:
// We can perform a longer save operation (e.g., upload to the cloud).
try
{
MainPage.DisplayToast("Performing a long save operation.");
cancellationTokenSource = new CancellationTokenSource();
await Task.Delay(TimeSpan.FromSeconds(10), cancellationTokenSource.Token);
MainPage.DisplayToast("Still saving.");
await Task.Delay(TimeSpan.FromSeconds(10), cancellationTokenSource.Token);
MainPage.DisplayToast("Long save complete.");
}
catch (TaskCanceledException) { }
break;
default:
case ExtendedExecutionResult.Denied:
// We must perform a fast save operation.
MainPage.DisplayToast("Performing a fast save operation.");
await Task.Delay(TimeSpan.FromSeconds(1));
MainPage.DisplayToast("Fast save complete.");
break;
}
session.Revoked -= ExtendedExecutionSessionRevoked;
}
suspendDeferral?.Complete();
suspendDeferral = null;
}
private async void ExtendedExecutionSessionRevoked(object sender, ExtendedExecutionRevokedEventArgs args)
{
//If session is revoked, make the OnSuspending event handler stop or the application will be terminated
if (cancellationTokenSource != null){ cancellationTokenSource.Cancel(); }
await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
{
switch (args.Reason)
{
case ExtendedExecutionRevokedReason.Resumed:
// A resumed app has returned to the foreground
rootPage.NotifyUser("Extended execution revoked due to returning to foreground.", NotifyType.StatusMessage);
break;
case ExtendedExecutionRevokedReason.SystemPolicy:
//An app can be in the foreground or background when a revocation due to system policy occurs
MainPage.DisplayToast("Extended execution revoked due to system policy.");
rootPage.NotifyUser("Extended execution revoked due to system policy.", NotifyType.StatusMessage);
break;
}
suspendDeferral?.Complete();
suspendDeferral = null;
});
}