Copied to clipboard

Flag this post as spam?

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


  • Elisha 9 posts 99 karma points
    Dec 03, 2020 @ 08:47
    Elisha
    0

    Umbraco Form submitted string gets splitted by comma

    I have an Umbraco Form with custom field. This custom field is generally a textbox enter image description here

    which on submit will contain string like this:

    "a,b,c"
    

    but when submitting it, inside ValidateField function, the postedValues list contains three strings: "a", "b", "c" it seems that the , (comma) recognized as a delimiter and then the string gets splitted in three. Is this something default in Umbraco Forms? If so, what is the way to prevent that from happening?

  • Huw Reddick 1727 posts 6066 karma points MVP c-trib
    Dec 03, 2020 @ 16:59
    Huw Reddick
    0

    yes, because this is generally the way html forms deal with things like checkboxlists, they get returned as a comma delimited string as the value for the form attribute, so that looks like what is happening, as to why that is happening when validating an input I'm no help I'm afraid, I don't use Forms.

  • Elisha 9 posts 99 karma points
    Dec 06, 2020 @ 05:46
    Elisha
    0

    Ok, but this should not be happening in case of a simple textbox (like in my case).

  • Huw Reddick 1727 posts 6066 karma points MVP c-trib
    Dec 06, 2020 @ 09:05
    Huw Reddick
    0

    do you have any other fields in the form with the same name ?

    If you make it text rather than hidden does it still behave the same?

  • Elisha 9 posts 99 karma points
    Dec 06, 2020 @ 10:56
    Elisha
    0

    No .. it is the only one in an entire form with that id. Also, no, even if I change to "text", still the result is the same .. I'm thinking maybe it somewhere in the code. What is happening in the middle between a form submission and entering ValidateField method inside Umbraco custom FormField class ?

  • Huw Reddick 1727 posts 6066 karma points MVP c-trib
    Dec 06, 2020 @ 11:12
    Huw Reddick
    0

    I don't mean the same ID I mean the same name, when http forms are posted the form attribute key is the name not the id, so if you have more than one item with the same name you will get a comma separated list of values for that form attribute. The ID is not used by http posts

    As I said, I can't tell you what the umbraco forms does as I don't use it, just offering some suggestions as to possible causes.

  • Elisha 9 posts 99 karma points
    Dec 06, 2020 @ 11:24
    Elisha
    0

    Thanks, Huw, but no, one occurence of the name is for the name itself, another one is for label for and the third one is for data-valmsg-for:

    enter image description here

Please Sign in or register to post replies

Write your reply to:

Draft