Umbraco Form submitted string gets splitted by comma
I have an Umbraco Form with custom field.
This custom field is generally a textbox
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?
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.
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 ?
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.
Umbraco Form submitted string gets splitted by comma
I have an Umbraco Form with custom field. This custom field is generally a textbox
which on submit will contain string like this:
but when submitting it, inside
ValidateField
function, thepostedValues
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?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.
Ok, but this should not be happening in case of a simple textbox (like in my case).
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?
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 enteringValidateField
method inside Umbraco customFormField
class ?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.
Thanks, Huw, but no, one occurence of the name is for the
name
itself, another one is forlabel for
and the third one is fordata-valmsg-for
:is working on a reply...