Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Corey 5 posts 75 karma points
    Jul 16, 2020 @ 13:50
    Corey
    0

    Change form field value during _FormValidate event

    Is it possible to change a form value during the UmbracoFormsController.FormValidate event? I have a hidden form field that needs to get populated with a formatted string based on other field entries.

    Can you provide a small code snippet for this?

    I've tried returning the field and setting its Values property, but that doesn't work.

    var field = e.Form.AllFields.SingleOrDefault(f => f.Alias == "key");
    field.Values = new List<object> { "test" };
    

    It does set the value during the request, but does not save to DB or fill in the form field when posting back (on model validation error).

Please Sign in or register to post replies

Write your reply to:

Draft