I need a selection list with one value, which is not the first value, preselected.
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | forms.module_0.patch | 3.55 KB | altano |
| #3 | forms.module.patch | 3.43 KB | altano |
I need a selection list with one value, which is not the first value, preselected.
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | forms.module_0.patch | 3.55 KB | altano |
| #3 | forms.module.patch | 3.43 KB | altano |
Comments
Comment #1
altano commentedThis isn't just a lack of support in the Forms project. form_select does not provide an option for default selection.
I'll look into it
Comment #2
altano commentedEr, I totally misread the api docs. Ignore the last post.
Comment #3
altano commentedHere's the patch
Comment #4
peterx commentedExcellent. 99% there. The code works except for one thing. I have a, *b, c. The * goes in to the key then is copied to the value. The * is detected and removed from the value but not the key. I quickly added an if() within the value code to remove * from the key. It works for *b.
The extra if() would not handle 1:a;*:*b;3:c where * is a valid key for value b.
Comment #5
altano commentedI'm not really following you. "a, *b, c" is not valid syntax?
Comment #6
peterx commentedThat should be a;*b;c. Using your examples from the code, 1:red;2:blue;3:*green works. The problem is with red;blue;*green. The code
$value = $key;copies *green from key to value.$value = substr($value, 1);then removes the * from the value but not the key.I added something to remove * from the key to fix the problem for my current list. I then thought about the problem and considered the example 1:red;2:blue;*:*green where * might be a required value. I have had * as a value in selection lists.
Comment #7
altano commentedSorry, Firefox wasn't refreshing the form for some reason so I didn't catch the bug. I guess I shouln't have tried so hard to keep the if/else block small :O
Here's another patch (restore to original first)
Comment #8
peterx commentedThe patch is working on my site for a;*b;c. Thank you.
Comment #9
quicksketchForms and survey modules are no longer being maintained, use Webform module instead.
---Closing down issue queue of survey module---