是否可以预先填充bot框架中的表单流字段? [英] Can form flow fields in bot framework be pre-populated?
问题描述
我已经使用formflow提出了几个问题,并最终填写了一个表单.唯一的ID生成并最终提供给用户.现在,使用该唯一ID,我要编辑表单.是否可以预先填充字段?还是有其他方法可以做到?
I have used formflow to ask several questions and to finally fill up a form. A unique id is generated and given to user at the end. Now using that unique id I want to edit the form. Is it possible to pre-populate the fields? Or is there any other way to do so?
这是我第一次用来创建表单的代码:
This is the code that I am using to create a form for first time:
public static IForm<AssesmentHelper> BuildForm()
{
OnCompletionAsyncDelegate<AssesmentHelper> wrapUpRequest = async (context, state) =>
{
//Do something....
};
return new FormBuilder<AssesmentHelper>()
.Message(Responses.NumberSelection)
.Field(nameof(Name))
.Field(nameof(Age))
.Field(nameof(Address))
.Field(nameof(Information))
.Field(nameof(Email), validate: ValidateMailId)
.AddRemainingFields()
.OnCompletion(wrapUpRequest)
.Build();
}
现在,我想预填充字段(名称,年龄,地址),以便也可以使用它进行编辑.
Now, I want to pre-populate fields (Name, Age, Address) so that I can use it for editing as well.
推荐答案
是的,您可以将Form状态/模型的实例传递给FormDialog并预先填充Form参数(如您看到的
Yes, you can pass an instance of your Form state/model to the FormDialog with the Form parameters pre-filled (as you can see here). Have in mind that . if you do that, any step for filling a field is skipped if that field has a value.
如果您仍然想询问那些参数,即使它们具有值;您必须更改FormOptions并使用
If you still want to ask for those parameters even if they have a value; you must change the FormOptions and use FormOptions.PromptFieldsWithValues, which will prompt for fields, but use the passed in state for defaults.
与此相关的文档位于此处.
这篇关于是否可以预先填充bot框架中的表单流字段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!