knop-project / knop

Web application framework for Lasso 8 and 9
18 stars 46 forks source link

Comma in select field value does not render in form #107

Open stevepiercy opened 9 years ago

stevepiercy commented 9 years ago

When a select field has a value that includes a comma, e.g., "Stockton, CA", and the user selects that option from the select menu and submits the form, Knop will write the value to the database and everything else, but it will not render the field with the value selected when the record is loaded a subsequent time.

stevepiercy commented 9 years ago

This is the line that breaks select options in both versions of Knop. https://github.com/knop-project/knop/blob/master/knop8/source/_ctype/form.inc#L1328 https://github.com/knop-project/knop/blob/master/knop9/knoplibs/knop_form.lasso#L1454

#fieldvalue_array = #fieldvalue_array -> (split: ',');

One could not use commas in their field values for checkboxes, radios, or selects, but that's a poor option.

The better option is to modify form.inc to accept an optional parameter flag -singlevalue with a default value of false for a given radio or select field. Then when the developer sets it to true, Knop will not split on the single value that contains commas.