Redo SingleChoiceSelection for better differentiation between required and optional selections#222
Conversation
This comment has been minimized.
This comment has been minimized.
| Choose one or abstain | ||
| </label> | ||
| <select id="flexident1" ...> | ||
| <option value="None" selected> |
There was a problem hiding this comment.
This should already be the case if you use SingleChoiceSelection. This value="None" is only offered for form type Maybe SingleChoiceSelection. If the field is required, then this is used instead:
flex-tasks/flex-tasks/src/FlexTask/Widgets.hs
Lines 141 to 145 in 14342ca
But I guess I should revise my custom selectField function to be less confusing. I just did a quick copy and edit on the standard Yesod version which resulted in messy code.
There was a problem hiding this comment.
currently, with formify (Nothing @SingleChoiceSelection), I'll get a dropdown where the value defaults to the first real value, and the None option is disabled:
I want it to default to None instead (the table is big so making it default to None makes it easy for students to see which dropdown they have not yet answered), but I also want the required check to take effect.
For this to work, perhaps what I need is just removing disabled from https://github.com/fmidue/flex-tasks/pull/222/changes#diff-26588820d6d6d6eb9930e0b89192489214299acf12c3b5043f1b362e02333b7bR774? what do you think ?
There was a problem hiding this comment.
Okay, I guess the behaviour is different between browsers. It did initially select the None option when I tried it on my setup, but did not allow reselecting it. I I will just remove the disabled attribute then.
There was a problem hiding this comment.
What browser are you using? I'd like to take a look at this again on Tuesday.

---options manually