3
votes

I don't need any confirmation before completion of my form. However, in the following Build() method of the FormBuilder class there is a Confirm("Is this your selection?\n{}")*.

    public IForm<T> Build()
    {
        if (!_form._steps.Any((step) => step.Type == StepType.Field))
        {
            var paths = new List<string>();
            FormBuilder<T>.FieldPaths(typeof(T), "", paths);
            IFormBuilder<T> builder = this;
            foreach (var path in paths)
            {
                builder.Field(new FieldReflector<T>(path));
            }
            builder.Confirm("Is this your selection?\n{*}");
        }
        Validate();
        return this._form;
    }

Is there any way I can remove this step from my generated Form after calling build ?

            var form =  new FormBuilder<QuestionYourThinking>()
            .OnCompletionAsync(async (context, state) =>
            {
                await context.PostAsync("L'exercice est maintenant terminé. A bientot !");
            })
            .Build();
2

2 Answers

7
votes

Just use the overload that take an ActiveDelegate parameter and make the method handler to return false then the confirmation message will not be shown.

return new FormBuilder<QuestionYourThinking>()
    .AddRemainingFields()
    .Confirm("No verification will be shown", state => false)
    .Message("L'exercice est maintenant terminé. A bientot !")
    .Build();

To send a message you can just use the fluent method Message.

0
votes

You can just use .AddRemainingFields() on your FormBuilder. It will not ask for any confirmation. .Confirm should be used when you want to add custom confirmation message for any specific field.