botframework-sdk icon indicating copy to clipboard operation
botframework-sdk copied to clipboard

[FormFlow] Warning, that selected field is wrong choice, when try to change field value

Open sawmixer opened this issue 9 years ago • 5 comments

Pre-flight checklist


System Information (Required)

  • SDK Platform: C#
  • SDK Version: 3.8.1
  • Development Environment: localhost

Issue Description

I made FormFlow dialog with two fields. When testing if I want to change any field, I press corresponding button and get warning, that selected field is wrong choice. It heppen on russian locale.

Example Code

My class

public class GetInfoForm
{
    [Describe("фамилия")]
    [Pattern(@"^[\s\S]+$")]
    public string SecondName { get; set; }

    [Describe("имя")]
    [Pattern(@"^[\s\S]+$")]
    public string FirstName { get; set; }

    public static IForm<GetInfoForm> BuildForm()
    {
        return new FormBuilder<GetInfoForm>()
            .Message("Заполните необходимые данные для получения информации")
            .Build();
    }
}

Method in MessagesController class

public async Task<HttpResponseMessage> Post([FromBody]Activity activity)
{
    if (activity.Type == ActivityTypes.Message)
    {
        await Conversation.SendAsync(activity, () => { return Chain.From(() => FormDialog.FromForm(GetInfoForm.BuildForm)); });
    }
    else
    {
        await HandleSystemMessageAsync(activity);
    }
    var response = Request.CreateResponse(HttpStatusCode.OK);
    return response;
}

Expected Behavior

The suggestion to enter a new value for the field.

Actual Results

emulator screenshot

sawmixer avatar May 26 '17 16:05 sawmixer

I've confirmed this behavior is repeatable using en-US. Still investigating.

EricDahlvang avatar May 30 '17 21:05 EricDahlvang

I'm not sure that this is a bug.

In fact, the problem here is that you need to define TermsAttribute for the matching, DescribeAttribue is not used for this (it is used for the display in your form): https://docs.microsoft.com/en-us/dotnet/api/microsoft.bot.builder.formflow.termsattribute?view=botbuilder-3.8

If Terms are not set up, the code is automatically trying to generate some terms (see here in code: https://github.com/Microsoft/BotBuilder/blob/master/CSharp/Library/Microsoft.Bot.Builder/FormFlow/FieldReflector.cs#L375) using the name of the field: _terms = new TermsAttribute(Language.GenerateTerms(Language.CamelCase(name), 3));

For example in your case, terms will be: seconds? + name+ seconds? name for SecondName field.

nrobert avatar Jun 14 '17 15:06 nrobert

Adding [Terms] attribute resolves the issue. However we trying to resolve this without having [Terms] attribute.

image

image

msmohan avatar Jun 19 '17 22:06 msmohan

Bug Fix has been submitted. Closing this thread.

msmohan avatar Jun 21 '17 17:06 msmohan

Great, thanks.

sawmixer avatar Jun 21 '17 18:06 sawmixer