Uploaded image for project: 'XWiki Platform'
  1. XWiki Platform
  2. XWIKI-344

Select with multiple=yes: cannot update to an empty selection

    XMLWordPrintable

Details

    Description

      • Create a ListProperty with "Multipe Select = yes", say "choice" with values "[a, b, c, d, e, f]"
      • Create such an object
      • Set "choice=[a, b, e]" and save the object
      • Edit again the object, and deselect all values, i.e. "choice=[]"
      • After saving, the old values are preserved, "choice=[a, b, e]"

      When submiting select elements with multiple choice, the browser sends to the server multiple "element=value" pairs, one for each selected option. The proble above is caused by the fact that for the form element no such pair gets submited. So XWiki cannot tell if the form element was included in the form or it had no selection.

      A fix for this would be:

      • When displaying the form element for editing, also display a hidden input with the same name, but with a bogus value, something like "******novalue******"
      • When the form gets submited, along with all the correct "element=value" pairs (possible none), the "element=******novalue******" pair gets submited too
      • When loading the property back from the submited form, if only ******novalue****** was received, then the property was included in the form, but no value was selected

      Attachments

        Activity

          People

            sdumitriu Sergiu Dumitriu
            sdumitriu Sergiu Dumitriu
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: