Hello,

I'm trying to set the default selected option for a SelectBox when a form is first displayed to be a particular value. After the user changes the value and stores the form the value selected by the user should be displayed the next time the form is displayed. I tried to do this by entering a global hash (see below), but I also tried this by setting the value manually with text. In both cases when I load the form for the first time the value that I set is not displayed correctly (the value is not selected in the drop-down selectbox). Any ideas why this might not be working? One hint: The form is being loaded as a sub-form.

  • No labels

5 Comments

  1. Hi Andrew,

    You almost got it working. The default value that you are setting there (which is correct) must be available as one of the options (selections) or else it will not be selected.

    Hope this clear things up.

    Cheers.

    1. Hi Hugo,

      It was available as one of the values. I checked this by using Firebug to check the option list generated by Joget, however the value was still not selected.

      Regards,

      Andrew

      1. Interesting. Let me check on this and I will get back to you soon!

        Cheers.

        1. Hi Andrew,

          I'm happy to inform you that I have failed to reproduce the problem that you are facing.

          I have created a App. APP_selectBoxTestApp-1-20121120163122.zip

          Please do the following:-

          1. Import the App and Publish it.

          2. Run the App using its Userview.

          3. Using the first item in the Userview, create few categories with ID ranging from 1 to 5. (Eg. 1. Category A, 2. Category B...)

          4. Click on the second item in the Userview. You will see a form with a subform inside. In the subform, you will find a Select Box with its options loaded from categories added earlier. The default value of the Select Box is read from Environment Variable "defaultCategoryId" with its value set as 3. Fill up the form, pick different category and submit.

          5. Click on the third item in the Userview. You will see the submitted form and its data. Click on Edit to load back the form submitted.


          Hope this will help.

          Cheers.

          1. I would like to precise an aspect of the solution presented by Hugo. The solution is working because the ID field in the form where the categories are created has been named "id". If this was not the case (let's say it was set to "idCategory")  the field ID Column of the form Select Form should have been set to "idCategory". Here a link to the explanation of the parameters that appears in the Select Form: Default Form Options Binder.

            Probably the only mistake in the Andrew solution was that he forgot to properly fill in the ID Column.